]> git.imager.perl.org - imager.git/blobdiff - bmp.c
freetype-config might not be available, allow pkg-config to work
[imager.git] / bmp.c
diff --git a/bmp.c b/bmp.c
index 0e8fe8e75c2ee9674106979f611612fcb5a3ca59..09cbf9c15197ca5b7416b4ff6d2987ba70a33e27 100644 (file)
--- a/bmp.c
+++ b/bmp.c
@@ -239,7 +239,7 @@ read_packed(io_glue *ig, char *format, ...) {
     switch (code) {
     case 'v':
       if (i_io_read(ig, buf, 2) != 2)
-       return 0;
+       goto fail;
       work = buf[0] + ((i_packed_t)buf[1] << 8);
       if (shrieking)
        *p = (work ^ SIGNBIT16) - SIGNBIT16;
@@ -249,7 +249,7 @@ read_packed(io_glue *ig, char *format, ...) {
 
     case 'V':
       if (i_io_read(ig, buf, 4) != 4)
-       return 0;
+       goto fail;
       work = buf[0] + (buf[1] << 8) + ((i_packed_t)buf[2] << 16) + ((i_packed_t)buf[3] << 24);
       if (shrieking)
        *p = (work ^ SIGNBIT32) - SIGNBIT32;
@@ -259,19 +259,19 @@ read_packed(io_glue *ig, char *format, ...) {
 
     case 'C':
       if (i_io_read(ig, buf, 1) != 1)
-       return 0;
+       goto fail;
       *p = buf[0];
       break;
 
     case 'c':
       if (i_io_read(ig, buf, 1) != 1)
-       return 0;
+       goto fail;
       *p = (char)buf[0];
       break;
       
     case '3': /* extension - 24-bit number */
       if (i_io_read(ig, buf, 3) != 3)
-        return 0;
+        goto fail;
       *p = buf[0] + (buf[1] << 8) + ((i_packed_t)buf[2] << 16);
       break;
       
@@ -282,7 +282,12 @@ read_packed(io_glue *ig, char *format, ...) {
       }
     }
   }
+  va_end(ap);
   return 1;
+
+ fail:
+  va_end(ap);
+  return 0;
 }
 
 /*
@@ -311,7 +316,7 @@ write_packed(io_glue *ig, char *format, ...) {
       buf[0] = i & 255;
       buf[1] = i / 256;
       if (i_io_write(ig, buf, 2) == -1)
-       return 0;
+       goto fail;
       break;
 
     case 'V':
@@ -320,14 +325,14 @@ write_packed(io_glue *ig, char *format, ...) {
       buf[2] = (i >> 16) & 0xFF;
       buf[3] = (i >> 24) & 0xFF;
       if (i_io_write(ig, buf, 4) == -1)
-       return 0;
+       goto fail;
       break;
 
     case 'C':
     case 'c':
       buf[0] = i & 0xFF;
       if (i_io_write(ig, buf, 1) == -1)
-       return 0;
+       goto fail;
       break;
 
     default:
@@ -341,6 +346,10 @@ write_packed(io_glue *ig, char *format, ...) {
   va_end(ap);
 
   return 1;
+
+ fail:
+  va_end(ap);
+  return 0;
 }
 
 /*
@@ -741,7 +750,7 @@ read_1bit_bmp(io_glue *ig, int xsize, int ysize, int clr_used,
     return NULL;
   }
 
-  if (xsize + 8 < xsize) { /* if there was overflow */
+  if ((i_img_dim)((i_img_dim_u)xsize + 8) < xsize) { /* if there was overflow */
     /* we check with 8 because we allocate that much for the decoded 
        line buffer */
     i_push_error(0, "integer overflow during memory allocation");