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;
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;
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;
}
}
}
+ va_end(ap);
return 1;
+
+ fail:
+ va_end(ap);
+ return 0;
}
/*
buf[0] = i & 255;
buf[1] = i / 256;
if (i_io_write(ig, buf, 2) == -1)
- return 0;
+ goto fail;
break;
case 'V':
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:
va_end(ap);
return 1;
+
+ fail:
+ va_end(ap);
+ return 0;
}
/*
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");
if (!clr_used)
clr_used = 2;
if (clr_used < 0 || clr_used > 2) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
clr_used = 16;
if (clr_used > 16 || clr_used < 0) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
else { /*if (compression == BI_RLE4) {*/
myfree(packed);
myfree(line);
- i_push_errorf(0, "unknown 4-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 4-bit BMP compression (%d)", compression);
i_img_destroy(im);
return NULL;
}
if (!clr_used)
clr_used = 256;
if (clr_used > 256 || clr_used < 0) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
}
else {
myfree(line);
- i_push_errorf(0, "unknown 8-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 8-bit BMP compression (%d)", compression);
i_img_destroy(im);
return NULL;
}
return 0;
}
if (rmask == 0) {
- i_push_errorf(0, "Zero mask for channel %d", i);
+ im_push_errorf(aIMCTX, 0, "Zero mask for channel %d", i);
return NULL;
}
masks.masks[i] = rmask;
base_offset += 3 * 4;
}
else {
- i_push_errorf(0, "unknown 24-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 24-bit BMP compression (%d)", compression);
return NULL;
}
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}