grub-probe: fix memory leak

Found by: Coverity scan.
CID: 73783
This commit is contained in:
Andrei Borzenkov 2016-01-16 21:47:28 +03:00
parent 77002c65d3
commit f826d914e2

View file

@ -279,7 +279,7 @@ probe (const char *path, char **device_names, char delim)
printf ("%s", *curdev); printf ("%s", *curdev);
putchar (delim); putchar (delim);
} }
return; goto free_device_names;
} }
if (print == PRINT_DISK) if (print == PRINT_DISK)
@ -297,7 +297,7 @@ probe (const char *path, char **device_names, char delim)
putchar (delim); putchar (delim);
free (disk); free (disk);
} }
return; goto free_device_names;
} }
for (curdev = device_names; *curdev; curdev++) for (curdev = device_names; *curdev; curdev++)
@ -669,6 +669,7 @@ probe (const char *path, char **device_names, char delim)
free (*curdrive); free (*curdrive);
free (drives_names); free (drives_names);
free_device_names:
if (path != NULL) if (path != NULL)
{ {
for (curdev = device_names; *curdev; curdev++) for (curdev = device_names; *curdev; curdev++)