about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-12-14 21:32:46 +0100
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2020-12-14 21:32:46 +0100
commit56a121e5ca3dfab07faa7de14e18273643124362 (patch)
treefef1e22518f98a5bcee9e63fd6c8049d9c5a3d82
parent1b09e9176fd9defecb91ebc735c383c6720d93d9 (diff)
fix(bs_bitmap_extend): fix crash with smaller than current size
-rw-r--r--bitmap.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/bitmap.c b/bitmap.c
index 36db96e..d9ac612 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -12,6 +12,9 @@ bool bs_bitmap_extend(bs_bitmap_t *b, int new_w, int new_h, unsigned char init)
   int diff_x = MAX(new_w - b->bs_bitmap_width, 0);
   int diff_y = MAX(new_h - b->bs_bitmap_height, 0);
 
+  new_w = MAX(new_w, b->bs_bitmap_width);
+  new_h = MAX(new_h, b->bs_bitmap_height);
+
   if(diff_y == 0 && diff_x == 0) {
     return true;
   }