]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Always initialise *relroot in grub_find_root_device_from_mountinfo,
authorColin Watson <cjwatson@ubuntu.com>
Fri, 7 Jan 2011 17:24:25 +0000 (17:24 +0000)
committerColin Watson <cjwatson@ubuntu.com>
Fri, 7 Jan 2011 17:24:25 +0000 (17:24 +0000)
otherwise we free an uninitialised pointer if /proc is unmounted.
Reported by: Scott Moser.

grub-core/kern/emu/getroot.c

index 373834127756848c0a06ee4f253b11a21e7d58e9..a4cfaffc93a89a1833ec66f8d951c269ce0df508 100644 (file)
@@ -111,13 +111,13 @@ grub_find_root_device_from_mountinfo (const char *dir, char **relroot)
   size_t len = 0;
   char *ret = NULL;
 
+  if (relroot)
+    *relroot = NULL;
+
   fp = fopen ("/proc/self/mountinfo", "r");
   if (! fp)
     return NULL; /* fall through to other methods */
 
-  if (relroot)
-    *relroot = NULL;
-
   while (getline (&buf, &len, fp) > 0)
     {
       int mnt_id, parent_mnt_id;