sds icon indicating copy to clipboard operation
sds copied to clipboard

Memleak in sds.c:40

Open vkazanov opened this issue 7 years ago • 0 comments

There's a possible memleak and NULL ptr usage in sds.c:40 in sdssplitargs:

vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
vector[*argc] = current;

Realloc here might return NULL and thus NULLify vector while losing the reference to original object. I believe something like the following should be done:

char** new_vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
if (new_vector == NULL) goto err;
vector = new_vector;
vector[*argc] = current;

vkazanov avatar Jan 19 '18 15:01 vkazanov