]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Haiku bitmap sanity checks
authorPo Lu <luangruo@yahoo.com>
Tue, 4 Jan 2022 02:21:23 +0000 (02:21 +0000)
committerPo Lu <luangruo@yahoo.com>
Tue, 4 Jan 2022 02:21:23 +0000 (02:21 +0000)
* src/haikufns.c (haiku_get_pixel, haiku_put_pixel): Fix sanity
checking of coordinate values.

src/haikufns.c

index 036da7975f84d2348a65b3a72c9ba34b2e88aa5d..6cd12f129c6c6f94f052eec3d94a5878b1e24def 100644 (file)
@@ -1238,7 +1238,7 @@ haiku_get_pixel (haiku bitmap, int x, int y)
   BBitmap_dimensions (bitmap, &left, &top, &right, &bottom,
                      &bytes_per_row, &mono_p);
 
-  if (x < left || x > right || y < top || y > bottom)
+  if (x < 0 || x > right - left || y < 0 || y > bottom - top)
     emacs_abort ();
 
   if (!mono_p)
@@ -1263,7 +1263,7 @@ haiku_put_pixel (haiku bitmap, int x, int y, unsigned long pixel)
   BBitmap_dimensions (bitmap, &left, &top, &right, &bottom,
                      &bytes_per_row, &mono_p);
 
-  if (x < left || x > right || y < top || y > bottom)
+  if (x < 0 || x > right - left || y < 0 || y > bottom - top)
     emacs_abort ();
 
   if (mono_p)