From: Uwe Hermann Date: Fri, 3 Apr 2015 20:02:00 +0000 (+0200) Subject: add_handle(): Fix a realloc() related issue. X-Git-Tag: libserialport-0.1.1~69 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ac323d80e0baaf6968c316dbcb2e5ffe4739cb2e;p=libserialport.git add_handle(): Fix a realloc() related issue. --- diff --git a/serialport.c b/serialport.c index 1ace0ae..5183a85 100644 --- a/serialport.c +++ b/serialport.c @@ -1165,13 +1165,12 @@ static enum sp_return add_handle(struct sp_event_set *event_set, sizeof(event_handle) * (event_set->count + 1)))) RETURN_ERROR(SP_ERR_MEM, "Handle array realloc() failed"); + event_set->handles = new_handles; + if (!(new_masks = realloc(event_set->masks, - sizeof(enum sp_event) * (event_set->count + 1)))) { - free(new_handles); + sizeof(enum sp_event) * (event_set->count + 1)))) RETURN_ERROR(SP_ERR_MEM, "Mask array realloc() failed"); - } - event_set->handles = new_handles; event_set->masks = new_masks; ((event_handle *) event_set->handles)[event_set->count] = handle;