]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-01-21 Vladimir Serbinenko <phcoder@gmail.com>
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 21 Jan 2010 23:07:28 +0000 (00:07 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 21 Jan 2010 23:07:28 +0000 (00:07 +0100)
* term/ieee1275/ofconsole.c (grub_ofconsole_dimensions): Allocate on
stack since heap is unavailable at that point.

ChangeLog
term/ieee1275/ofconsole.c

index f5bb1617b0595799543895e98f251e25e501f9a5..f227f5dbc76bf783a08592ac0118e213d027c3a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-21  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * term/ieee1275/ofconsole.c (grub_ofconsole_dimensions): Allocate on
+       stack since heap is unavailable at that point.
+
 2010-01-21  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/i386/bsd.h (FREEBSD_N_BIOS_GEOM): Removed.
index dd4270efffcc1aac2b6b92440f89a4159b3319ad..3799e2e273939e045197eed7a98852fff7eb011c 100644 (file)
@@ -245,37 +245,28 @@ static void
 grub_ofconsole_dimensions (void)
 {
   grub_ieee1275_ihandle_t options;
-  char *val;
   grub_ssize_t lval;
 
   if (! grub_ieee1275_finddevice ("/options", &options)
       && options != (grub_ieee1275_ihandle_t) -1)
     {
       if (! grub_ieee1275_get_property_length (options, "screen-#columns",
-                                              &lval) && lval != -1)
+                                              &lval)
+         && lval >= 0 && lval < 1024)
        {
-         val = grub_malloc (lval);
-         if (val)
-           {
-             if (! grub_ieee1275_get_property (options, "screen-#columns",
-                                               val, lval, 0))
-               grub_ofconsole_width = (grub_uint8_t) grub_strtoul (val, 0, 10);
-
-             grub_free (val);
-           }
+         char val[lval];
+
+         if (! grub_ieee1275_get_property (options, "screen-#columns",
+                                           val, lval, 0))
+           grub_ofconsole_width = (grub_uint8_t) grub_strtoul (val, 0, 10);
        }
-      if (! grub_ieee1275_get_property_length (options, "screen-#rows",
-                                              &lval) && lval != -1)
+      if (! grub_ieee1275_get_property_length (options, "screen-#rows", &lval)
+         && lval >= 0 && lval < 1024)
        {
-         val = grub_malloc (lval);
-         if (val)
-           {
-             if (! grub_ieee1275_get_property (options, "screen-#rows",
-                                               val, lval, 0))
-               grub_ofconsole_height = (grub_uint8_t) grub_strtoul (val, 0, 10);
-
-             grub_free (val);
-           }
+         char val[lval];
+         if (! grub_ieee1275_get_property (options, "screen-#rows",
+                                           val, lval, 0))
+           grub_ofconsole_height = (grub_uint8_t) grub_strtoul (val, 0, 10);
        }
     }