forked from RepoMirrors/bemenu
Store tmp to tokv in for loop, so we can free it if something fails.
This commit is contained in:
parent
6692f73c5c
commit
5599e1aa8e
@ -57,8 +57,8 @@ static char* _bmFilterTokenize(bmMenu *menu, char ***outTokv, unsigned int *outT
|
|||||||
size_t pos = 0, next;
|
size_t pos = 0, next;
|
||||||
unsigned int tokc = 0, tokn = 0;
|
unsigned int tokc = 0, tokn = 0;
|
||||||
char *s = buffer, **tmp = NULL;
|
char *s = buffer, **tmp = NULL;
|
||||||
while ((pos = _bmStripToken(s, " ", &next)) > 0) {
|
for (; (pos = _bmStripToken(s, " ", &next)) > 0; tokv = tmp) {
|
||||||
if (++tokc > tokn && !(tmp = realloc(tmp, ++tokn * sizeof(char*))))
|
if (++tokc > tokn && !(tmp = realloc(tokv, ++tokn * sizeof(char*))))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
tmp[tokc - 1] = s;
|
tmp[tokc - 1] = s;
|
||||||
|
Loading…
Reference in New Issue
Block a user