1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-11 05:55:58 +00:00

Fixed memory leak in png_to_file if NO_PNG is defined

This commit is contained in:
tgotic
2011-01-25 00:40:56 +01:00
parent 19cb13791b
commit a00804494b

View File

@@ -453,7 +453,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
int error_number;
float scaler = symbol->scale;
char *scaled_pixelbuf;
int horiz, vert, i;
int horiz, vert;
int scale_width, scale_height;
if(scaler == 0) { scaler = 0.5; }
@@ -461,14 +461,11 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
scale_height = image_height * scaler;
/* Apply scale options by creating another pixel buffer */
if (!(scaled_pixelbuf = (char *) malloc(scale_width * scale_height))) {
if ((scaled_pixelbuf = (char *) malloc(scale_width * scale_height)) == NULL) {
printf("Insufficient memory for pixel buffer");
return ZERROR_ENCODING_PROBLEM;
} else {
for(i = 0; i < (scale_width * scale_height); i++) {
*(scaled_pixelbuf + i) = '0';
}
}
memset(scaled_pixelbuf, '0', scale_width * scale_height);
for(vert = 0; vert < scale_height; vert++) {
for(horiz = 0; horiz < scale_width; horiz++) {
@@ -480,7 +477,7 @@ int png_to_file(struct zint_symbol *symbol, int image_height, int image_width, c
#ifndef NO_PNG
error_number = png_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle);
#else
return ZERROR_INVALID_OPTION;
error_number = ZERROR_INVALID_OPTION;
#endif
} else {
error_number = bmp_pixel_plot(symbol, scale_height, scale_width, scaled_pixelbuf, rotate_angle);