Fix uninitialized use of ret in expr(1)

This commit is contained in:
sin 2014-11-16 14:43:10 +00:00
parent b3ae1a7b4b
commit 7b8d7fb78e
1 changed files with 4 additions and 3 deletions

7
expr.c
View File

@ -117,10 +117,11 @@ match(Val vstr, Val vregx)
if (re.re_nsub) {
len = matches[1].rm_eo - matches[1].rm_so + 1;
ret = emalloc(len); /* TODO: free ret */
d = strtoimax(ret, &p, 10);
ret = malloc(len); /* TODO: free ret */
if (!ret)
enprintf(3, "malloc:");
strlcpy(ret, str + matches[1].rm_so, len);
d = strtoimax(ret, &p, 10);
if (*ret && !*p)
return (Val){ NULL, d };
return (Val){ ret, 0 };