add_handle(): Fix a realloc() related issue.
This commit is contained in:
parent
e019e72ec0
commit
ac323d80e0
11
serialport.c
11
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");
|
||||
|
||||
if (!(new_masks = realloc(event_set->masks,
|
||||
sizeof(enum sp_event) * (event_set->count + 1)))) {
|
||||
free(new_handles);
|
||||
RETURN_ERROR(SP_ERR_MEM, "Mask array realloc() failed");
|
||||
}
|
||||
|
||||
event_set->handles = new_handles;
|
||||
|
||||
if (!(new_masks = realloc(event_set->masks,
|
||||
sizeof(enum sp_event) * (event_set->count + 1))))
|
||||
RETURN_ERROR(SP_ERR_MEM, "Mask array realloc() failed");
|
||||
|
||||
event_set->masks = new_masks;
|
||||
|
||||
((event_handle *) event_set->handles)[event_set->count] = handle;
|
||||
|
|
Loading…
Reference in New Issue