case 'd':
p = va_arg(ap, long *);
- *p = bufp[0] + (bufp[1] << 8) + (bufp[2] << 16) + (bufp[3] << 24);
+ *p = bufp[0] + (bufp[1] << 8) + (bufp[2] << 16) + ((unsigned long)bufp[3] << 24);
bufp += 4;
break;
static int
write_1_bit(i_io_glue_t *ig, ico_image_t const *image, int *error) {
int line_size = (image->width + 31) / 32 * 4;
- unsigned char *writebuf = malloc(line_size);
+ unsigned char *writebuf;
unsigned char *outp;
unsigned char const *data, *pixelp;
int x,y;
if (!write_palette(ig, image, error))
return 0;
+ writebuf = malloc(line_size);
if (!writebuf) {
*error = ICOERR_Out_Of_Memory;
return 0;