mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
cppcheck: fix reports
[backend/bmp.c:133]: (error) Memory leak: bitmap [backend/bmp.c:126]: (error) Memory leak: bitmap [backend/composite.c:464]: (error) Array index -1 is out of bounds. [backend/composite.c:507]: (error) Array index -1 is out of bounds. [backend/dmatrix.c:962]: (style) Redundant condition: i!=0. 'i==0 || (i!=0 && binary[i-1]!='b')' is equivalent to 'i==0 || binary[i-1]!='b'' [backend/raster.c:122]: (error) Memory leak: rotated_pixbuf [backend/raster.c:506]: (error) Memory leak: pixelbuf [frontend/main.c:273]: (error) Uninitialized variable: format_string [frontend_qt/exportwindow.cpp:103]: (style) Array index 'j' is used before limits check.
This commit is contained in:
parent
0d6716a773
commit
3257a5c0af
@ -123,12 +123,16 @@ int bmp_pixel_plot(struct zint_symbol *symbol, char *pixelbuf) {
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
|
if (-1 == _setmode(_fileno(stdout), _O_BINARY)) {
|
||||||
strcpy(symbol->errtxt, "Can't open output file");
|
strcpy(symbol->errtxt, "Can't open output file");
|
||||||
|
free(bitmap_file_start);
|
||||||
|
free(bitmap);
|
||||||
return ZINT_ERROR_FILE_ACCESS;
|
return ZINT_ERROR_FILE_ACCESS;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bmp_file = stdout;
|
bmp_file = stdout;
|
||||||
} else {
|
} else {
|
||||||
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
|
if (!(bmp_file = fopen(symbol->outfile, "wb"))) {
|
||||||
|
free(bitmap_file_start);
|
||||||
|
free(bitmap);
|
||||||
strcpy(symbol->errtxt, "Can't open output file (F00)");
|
strcpy(symbol->errtxt, "Can't open output file (F00)");
|
||||||
return ZINT_ERROR_FILE_ACCESS;
|
return ZINT_ERROR_FILE_ACCESS;
|
||||||
}
|
}
|
||||||
|
@ -461,6 +461,7 @@ static int cc_b(struct zint_symbol *symbol, char source[], int cc_width) {
|
|||||||
|
|
||||||
/* Now we have the variant we can load the data - from here on the same as MicroPDF417 code */
|
/* Now we have the variant we can load the data - from here on the same as MicroPDF417 code */
|
||||||
variant--;
|
variant--;
|
||||||
|
assert(variant >= 0);
|
||||||
symbol->option_2 = MicroVariants[variant]; /* columns */
|
symbol->option_2 = MicroVariants[variant]; /* columns */
|
||||||
symbol->rows = MicroVariants[variant + 34]; /* rows */
|
symbol->rows = MicroVariants[variant + 34]; /* rows */
|
||||||
k = MicroVariants[variant + 68]; /* number of EC CWs */
|
k = MicroVariants[variant + 68]; /* number of EC CWs */
|
||||||
|
@ -959,7 +959,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (i < tp) {
|
while (i < tp) {
|
||||||
if (binary[i] == 'b') {
|
if (binary[i] == 'b') {
|
||||||
if ((i == 0) || ((i != 0) && (binary[i - 1] != 'b'))) {
|
if ((i == 0) || (binary[i - 1] != 'b')) {
|
||||||
/* start of binary data */
|
/* start of binary data */
|
||||||
int binary_count; /* length of b256 data */
|
int binary_count; /* length of b256 data */
|
||||||
|
|
||||||
|
@ -119,20 +119,24 @@ int save_raster_image_to_file(struct zint_symbol *symbol, int image_height, int
|
|||||||
|
|
||||||
if (strlen(symbol->fgcolour) != 6) {
|
if (strlen(symbol->fgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "Malformed foreground colour target (F51)");
|
strcpy(symbol->errtxt, "Malformed foreground colour target (F51)");
|
||||||
|
free(rotated_pixbuf);
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
if (strlen(symbol->bgcolour) != 6) {
|
if (strlen(symbol->bgcolour) != 6) {
|
||||||
strcpy(symbol->errtxt, "Malformed background colour target (F52)");
|
strcpy(symbol->errtxt, "Malformed background colour target (F52)");
|
||||||
|
free(rotated_pixbuf);
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*) symbol->fgcolour, strlen(symbol->fgcolour));
|
error_number = is_sane(SSET, (unsigned char*) symbol->fgcolour, strlen(symbol->fgcolour));
|
||||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed foreground colour target (F53)");
|
strcpy(symbol->errtxt, "Malformed foreground colour target (F53)");
|
||||||
|
free(rotated_pixbuf);
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
error_number = is_sane(SSET, (unsigned char*) symbol->bgcolour, strlen(symbol->fgcolour));
|
error_number = is_sane(SSET, (unsigned char*) symbol->bgcolour, strlen(symbol->fgcolour));
|
||||||
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
if (error_number == ZINT_ERROR_INVALID_DATA) {
|
||||||
strcpy(symbol->errtxt, "Malformed background colour target (F54)");
|
strcpy(symbol->errtxt, "Malformed background colour target (F54)");
|
||||||
|
free(rotated_pixbuf);
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,6 +185,7 @@ int save_raster_image_to_file(struct zint_symbol *symbol, int image_height, int
|
|||||||
#ifndef NO_PNG
|
#ifndef NO_PNG
|
||||||
error_number = png_pixel_plot(symbol, rotated_pixbuf);
|
error_number = png_pixel_plot(symbol, rotated_pixbuf);
|
||||||
#else
|
#else
|
||||||
|
free(rotated_pixbuf);
|
||||||
return ZINT_ERROR_INVALID_OPTION;
|
return ZINT_ERROR_INVALID_OPTION;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
@ -503,6 +508,7 @@ int plot_raster_maxicode(struct zint_symbol *symbol, int rotate_angle, int data_
|
|||||||
if (!(scaled_hexagon = (char *) malloc(hexagon_size * hexagon_size))) {
|
if (!(scaled_hexagon = (char *) malloc(hexagon_size * hexagon_size))) {
|
||||||
strcpy(symbol->errtxt, "Insufficient memory for pixel buffer (F56)");
|
strcpy(symbol->errtxt, "Insufficient memory for pixel buffer (F56)");
|
||||||
free(scaled_hexagon);
|
free(scaled_hexagon);
|
||||||
|
free(pixelbuf);
|
||||||
return ZINT_ERROR_ENCODING_PROBLEM;
|
return ZINT_ERROR_ENCODING_PROBLEM;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < (hexagon_size * hexagon_size); i++) {
|
for (i = 0; i < (hexagon_size * hexagon_size); i++) {
|
||||||
|
@ -266,6 +266,7 @@ int batch_process(struct zint_symbol *symbol, char *filename, int mirror_mode, c
|
|||||||
char adjusted[2];
|
char adjusted[2];
|
||||||
|
|
||||||
memset(buffer, 0, sizeof (unsigned char) * 7100);
|
memset(buffer, 0, sizeof (unsigned char) * 7100);
|
||||||
|
memset(format_string, 0, sizeof (unsigned char) * 127);
|
||||||
if (symbol->outfile[0] == '\0') {
|
if (symbol->outfile[0] == '\0') {
|
||||||
strcpy(format_string, "~~~~~.");
|
strcpy(format_string, "~~~~~.");
|
||||||
strcat(format_string, filetype);
|
strcat(format_string, filetype);
|
||||||
|
@ -100,7 +100,7 @@ void ExportWindow::process()
|
|||||||
|
|
||||||
for(i = 0; i < lines; i++) {
|
for(i = 0; i < lines; i++) {
|
||||||
datalen = 0;
|
datalen = 0;
|
||||||
for(j = inputpos; ((output_data[j] != '\n') && (j < output_data.length())); j++) {
|
for(j = inputpos; ((j < output_data.length()) && (output_data[j] != '\n') ); j++) {
|
||||||
datalen++;
|
datalen++;
|
||||||
}
|
}
|
||||||
dataString = output_data.mid(inputpos, datalen);
|
dataString = output_data.mid(inputpos, datalen);
|
||||||
|
Loading…
Reference in New Issue
Block a user