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:
22
backend/ps.c
22
backend/ps.c
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user