Partial fix for #750

master
Pierre Joye 2021-09-07 22:03:21 +07:00
parent c80a7bf3ff
commit e5c84f0b7a
2 changed files with 17 additions and 4 deletions

View File

@ -266,7 +266,11 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
bitmap_size += compressed_size;
gdPutBuf(uncompressed_row, compressed_size, out);
if (gdPutBuf(uncompressed_row, compressed_size, out) != compressed_size){
gd_error("gd-bmp write error\n");
error = 1;
break;
}
gdPutC(BMP_RLE_COMMAND, out);
gdPutC(BMP_RLE_ENDOFLINE, out);
bitmap_size += 2;
@ -322,10 +326,14 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
}
while ((buffer_size = gdGetBuf(copy_buffer, 1024, out)) != EOF) {
int res;
if (buffer_size == 0) {
break;
}
gdPutBuf(copy_buffer , buffer_size, out_original);
if (gdPutBuf(copy_buffer , buffer_size, out_original) != buffer_size) {
gd_error("gd-bmp write error\n");
error = 1;
}
}
gdFree(copy_buffer);
@ -335,7 +343,7 @@ static int _gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression)
out_original = NULL;
}
ret = 0;
ret = error;
cleanup:
if (tmpfile_for_compression) {
#ifdef _WIN32

View File

@ -227,8 +227,13 @@ static int _gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
ret = 1;
goto freeargb;
}
gdPutBuf(out, out_size, outfile);
int res = gdPutBuf(out, out_size, outfile);
free(out);
if (res != out_size) {
gd_error("gd-webp write error\n");
ret = 1;
}
freeargb:
gdFree(argb);