mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Fix list append.
This commit is contained in:
parent
68ab64ccdc
commit
db2794cea9
@ -56,12 +56,13 @@ static char **sp_list_append(char **list, void *data, size_t len)
|
|||||||
void *tmp;
|
void *tmp;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
for (count = 0; list[count]; count++);
|
for (count = 0; list[count]; count++);
|
||||||
if (!(tmp = realloc(list, sizeof(char *) * (++count + 1))))
|
if (!(tmp = realloc(list, sizeof(char *) * (count + 2))))
|
||||||
goto fail;
|
goto fail;
|
||||||
list = tmp;
|
list = tmp;
|
||||||
if (!(list[count] = malloc(len)))
|
if (!(list[count] = malloc(len)))
|
||||||
goto fail;
|
goto fail;
|
||||||
memcpy(list[count], data, len);
|
memcpy(list[count], data, len);
|
||||||
|
list[count + 1] = NULL;
|
||||||
return list;
|
return list;
|
||||||
fail:
|
fail:
|
||||||
sp_free_port_list(list);
|
sp_free_port_list(list);
|
||||||
|
Loading…
Reference in New Issue
Block a user