Commit 8cd6afe9 authored by Daan Vreeken's avatar Daan Vreeken
Browse files

Keep controller_load_check_arg() from crashing when filename doesn't contain '/'.

'slash' would be used uninitialized in this case. While we're here, change
code to use strrchr() instead of rolling our own and only stat() a filename if
we've found a '/', since we know 'extern->filename' will not contain a
directory name otherwise.

	modified:   controller/controller_load.c
parent ff394fc1
......@@ -293,10 +293,12 @@ static char *rel2file(yyscan_t scanner, char *rel_name)
return NULL;
tmp = strdup(extra->filename);
for (ret = tmp; *ret; ret++)
if (*ret == '/')
slash = ret;
*slash = 0;
slash = strrchr(tmp, '/');
if (slash == NULL) {
free(tmp);
return NULL;
}
*slash = '\0';
asprintf(&ret, "%s/%s", tmp, rel_name);
free(tmp);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment