sparcPromPathname2Node: free name when returning error, instead of leaking it
Reported with other leaks found by cppcheck in bugzilla #50281 https://bugs.freedesktop.org/show_bug.cgi?id=50281 Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
174ccd8493
commit
2b361fbda5
@ -617,8 +617,10 @@ sparcPromPathname2Node(const char *pathName)
|
|||||||
return 0;
|
return 0;
|
||||||
strcpy(name, pathName);
|
strcpy(name, pathName);
|
||||||
name[i + 1] = 0;
|
name[i + 1] = 0;
|
||||||
if (name[0] != '/')
|
if (name[0] != '/') {
|
||||||
|
free(name);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
p = strchr(name + 1, '/');
|
p = strchr(name + 1, '/');
|
||||||
if (p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
@ -629,8 +631,10 @@ sparcPromPathname2Node(const char *pathName)
|
|||||||
*regstr++ = 0;
|
*regstr++ = 0;
|
||||||
else
|
else
|
||||||
regstr = p;
|
regstr = p;
|
||||||
if (name + 1 == regstr)
|
if (name + 1 == regstr) {
|
||||||
|
free(name);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
promGetSibling(0);
|
promGetSibling(0);
|
||||||
i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0);
|
i = promWalkPathname2Node(name + 1, regstr, promRootNode, 0);
|
||||||
free(name);
|
free(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user