]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/term/serial.c (grub_serial_register): Fix invalid free.
authorVladimir Serbinenko <phcoder@gmail.com>
Sun, 26 Jan 2014 01:36:05 +0000 (02:36 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Sun, 26 Jan 2014 01:36:05 +0000 (02:36 +0100)
Ensure that pointers are inited to NULL and that pointers are not
accessed after free.

ChangeLog
grub-core/term/serial.c

index c93f11fbb205f5d7e332a54f5b5ccd40bf64c7ba..67b4d5c2add875a0b617f50325de36a54acf8a0d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-26  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/term/serial.c (grub_serial_register): Fix invalid free.
+       Ensure that pointers are inited to NULL and that pointers are not
+       accessed after free.
 
 2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
 
index b581a763ed0ea402ba3339205d1c3946eab30ebc..c9b5574ae3cc53013dbb5cddc691687e74f67ce2 100644 (file)
@@ -338,23 +338,23 @@ grub_serial_register (struct grub_serial_port *port)
       grub_free (indata);
       return grub_errno;
     }
-  
-  out = grub_malloc (sizeof (*out));
+
+  out = grub_zalloc (sizeof (*out));
   if (!out)
     {
-      grub_free (in);
       grub_free (indata);
       grub_free ((char *) in->name);
+      grub_free (in);
       return grub_errno;
     }
 
   outdata = grub_malloc (sizeof (*outdata));
   if (!outdata)
     {
-      grub_free (in);
       grub_free (indata);
       grub_free ((char *) in->name);
       grub_free (out);
+      grub_free (in);
       return grub_errno;
     }