]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/gfxmenu/gui_image.c (rescale_image): Don't attempt to scale
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Apr 2011 07:16:44 +0000 (09:16 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Apr 2011 07:16:44 +0000 (09:16 +0200)
to negative size.

ChangeLog
grub-core/gfxmenu/gui_image.c

index 47935890d21a7a6382d671a74841f4f020e35006..572d49a136d94601686c91d964677b1f635b9c96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-16  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/gfxmenu/gui_image.c (rescale_image): Don't attempt to scale
+       to negative size.
+
 2011-04-13  Colin Watson  <cjwatson@ubuntu.com>
 
        * util/grub.d/10_linux.in: Add rootflags=subvol=<name> if / is on a
index 3988f4ba81de106802275f14d4233750b47fa19d..60e4a46de70a27c872fd94991397151eb996dd75 100644 (file)
@@ -101,6 +101,9 @@ image_get_parent (void *vself)
 static grub_err_t
 rescale_image (grub_gui_image_t self)
 {
+  signed width;
+  signed height;
+
   if (! self->raw_bitmap)
     {
       if (self->bitmap)
@@ -111,12 +114,12 @@ rescale_image (grub_gui_image_t self)
       return grub_errno;
     }
 
-  unsigned width = self->bounds.width;
-  unsigned height = self->bounds.height;
+  width = self->bounds.width;
+  height = self->bounds.height;
 
   if (self->bitmap
-      && (grub_video_bitmap_get_width (self->bitmap) == width)
-      && (grub_video_bitmap_get_height (self->bitmap) == height))
+      && ((signed) grub_video_bitmap_get_width (self->bitmap) == width)
+      && ((signed) grub_video_bitmap_get_height (self->bitmap) == height))
     {
       /* Nothing to do; already the right size.  */
       return grub_errno;
@@ -131,15 +134,15 @@ rescale_image (grub_gui_image_t self)
 
   /* Create a scaled bitmap, unless the requested size is the same
      as the raw size -- in that case a reference is made.  */
-  if (grub_video_bitmap_get_width (self->raw_bitmap) == width
-      && grub_video_bitmap_get_height (self->raw_bitmap) == height)
+  if ((signed) grub_video_bitmap_get_width (self->raw_bitmap) == width
+      && (signed) grub_video_bitmap_get_height (self->raw_bitmap) == height)
     {
       self->bitmap = self->raw_bitmap;
       return grub_errno;
     }
 
   /* Don't scale to an invalid size.  */
-  if (width == 0 || height == 0)
+  if (width <= 0 || height <= 0)
     return grub_errno;
 
   /* Create the scaled bitmap.  */