1
0
mirror of https://git.code.sf.net/p/zint/code synced 2026-01-10 21:45:58 +00:00

fixed resource leaks for invalid colours

This commit is contained in:
tgotic
2011-01-25 00:41:59 +01:00
parent a00804494b
commit d31a7c8947
2 changed files with 23 additions and 21 deletions

View File

@@ -54,17 +54,7 @@ int ps_plot(struct zint_symbol *symbol)
strcpy(addon, "");
comp_offset = 0;
addon_text_posn = 0.0;
if((symbol->output_options & BARCODE_STDOUT) != 0) {
feps = stdout;
} else {
feps = fopen(symbol->outfile, "w");
}
if(feps == NULL) {
strcpy(symbol->errtxt, "Could not open output file");
return ZERROR_FILE_ACCESS;
}
/* sort out colour options */
to_upper((unsigned char*)symbol->fgcolour);
to_upper((unsigned char*)symbol->bgcolour);
@@ -87,6 +77,16 @@ int ps_plot(struct zint_symbol *symbol)
strcpy(symbol->errtxt, "Malformed background colour target");
return ZERROR_INVALID_OPTION;
}
if((symbol->output_options & BARCODE_STDOUT) != 0) {
feps = stdout;
} else {
feps = fopen(symbol->outfile, "w");
}
if(feps == NULL) {
strcpy(symbol->errtxt, "Could not open output file");
return ZERROR_FILE_ACCESS;
}
locale = setlocale(LC_ALL, "C");
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);

View File

@@ -51,16 +51,7 @@ int svg_plot(struct zint_symbol *symbol)
comp_offset = 0;
addon_text_posn = 0.0;
if((symbol->output_options & BARCODE_STDOUT) != 0) {
fsvg = stdout;
} else {
fsvg = fopen(symbol->outfile, "w");
}
if(fsvg == NULL) {
strcpy(symbol->errtxt, "Could not open output file");
return ZERROR_FILE_ACCESS;
}
/* sort out colour options */
to_upper((unsigned char*)symbol->fgcolour);
to_upper((unsigned char*)symbol->bgcolour);
@@ -83,6 +74,17 @@ int svg_plot(struct zint_symbol *symbol)
strcpy(symbol->errtxt, "Malformed background colour target");
return ZERROR_INVALID_OPTION;
}
if((symbol->output_options & BARCODE_STDOUT) != 0) {
fsvg = stdout;
} else {
fsvg = fopen(symbol->outfile, "w");
}
if(fsvg == NULL) {
strcpy(symbol->errtxt, "Could not open output file");
return ZERROR_FILE_ACCESS;
}
locale = setlocale(LC_ALL, "C");
fgred = (16 * ctoi(symbol->fgcolour[0])) + ctoi(symbol->fgcolour[1]);