grub-probe: fix memory leak
authorAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 10:49:37 +0000 (13:49 +0300)
committerAndrei Borzenkov <arvidjaar@gmail.com>
Sat, 9 Jan 2016 10:55:28 +0000 (13:55 +0300)
Found by: Coverity scan.
CID: 73783

util/grub-probe.c

index b1f5336..36b7f8b 100644 (file)
@@ -668,6 +668,13 @@ probe (const char *path, char **device_names, char delim)
   for (curdrive = drives_names; *curdrive; curdrive++)
     free (*curdrive);
   free (drives_names);
+
+  if (path != NULL)
+    {
+      for (curdev = device_names; *curdev; curdev++)
+       free (*curdev);
+      free (device_names);
+    }
 }
 
 static struct argp_option options[] = {