Store tmp to tokv in for loop, so we can free it if something fails.

This commit is contained in:
Jari Vetoniemi 2014-04-12 20:52:01 +03:00
parent 6692f73c5c
commit 5599e1aa8e

View File

@ -57,8 +57,8 @@ static char* _bmFilterTokenize(bmMenu *menu, char ***outTokv, unsigned int *outT
size_t pos = 0, next;
unsigned int tokc = 0, tokn = 0;
char *s = buffer, **tmp = NULL;
while ((pos = _bmStripToken(s, " ", &next)) > 0) {
if (++tokc > tokn && !(tmp = realloc(tmp, ++tokn * sizeof(char*))))
for (; (pos = _bmStripToken(s, " ", &next)) > 0; tokv = tmp) {
if (++tokc > tokn && !(tmp = realloc(tokv, ++tokn * sizeof(char*))))
goto fail;
tmp[tokc - 1] = s;