Fix memory leak in PostScript

Also match ZBarcode_Encode prototype with definition
Fixes thanks to Alex Haley <ahaley42@sf>, Ref ticket #33
This commit is contained in:
Robin Stuart 2016-09-13 21:30:19 +01:00
parent 343b3b873e
commit b49f3f0255
2 changed files with 37 additions and 18 deletions

View file

@ -106,6 +106,9 @@ int ps_plot(struct zint_symbol *symbol) {
}
if (feps == NULL) {
strcpy(symbol->errtxt, "Could not open output file");
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_FILE_ACCESS;
}
@ -116,23 +119,35 @@ int ps_plot(struct zint_symbol *symbol) {
if (strlen(symbol->fgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed foreground colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
if (strlen(symbol->bgcolour) != 6) {
strcpy(symbol->errtxt, "Malformed background colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->fgcolour, strlen(symbol->fgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed foreground colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
error_number = is_sane(SSET, (unsigned char*) symbol->bgcolour, strlen(symbol->bgcolour));
if (error_number == ZINT_ERROR_INVALID_DATA) {
strcpy(symbol->errtxt, "Malformed background colour target");
fclose(feps);
#ifdef _MSC_VER
free(local_text);
#endif
return ZINT_ERROR_INVALID_OPTION;
}
locale = setlocale(LC_ALL, "C");
@ -951,5 +966,9 @@ int ps_plot(struct zint_symbol *symbol) {
if (locale)
setlocale(LC_ALL, locale);
#ifdef _MSC_VER
free(local_text);
#endif
return error_number;
}