Avoid SIGSEGV on Code 128 input too long

This commit is contained in:
Robin Stuart 2017-07-26 11:44:47 +01:00
parent 24f175b6f6
commit e81a90bb58

View File

@ -809,7 +809,7 @@ static int reduced_charset(struct zint_symbol *symbol, const unsigned char *sour
case BARCODE_CODABLOCKF: error_number = codablock(symbol, preprocessed, in_length); case BARCODE_CODABLOCKF: error_number = codablock(symbol, preprocessed, in_length);
break; break;
} }
return error_number; return error_number;
} }
@ -1060,18 +1060,16 @@ int ZBarcode_Encode(struct zint_symbol *symbol, const unsigned char *source,int
} }
if ((symbol->symbology == BARCODE_CODE128) || (symbol->symbology == BARCODE_CODE128B)) { if (error_number == 0) {
for (i = 0; i < in_length; i++) { if ((symbol->symbology == BARCODE_CODE128) || (symbol->symbology == BARCODE_CODE128B)) {
if (local_source[i] == '\0') { for (i = 0; i < in_length; i++) {
symbol->text[i] = ' '; if (local_source[i] == '\0') {
} else { symbol->text[i] = ' ';
symbol->text[i] = local_source[i]; } else {
symbol->text[i] = local_source[i];
}
} }
} }
}
if (error_number == 0) {
error_number = error_buffer; error_number = error_buffer;
} }
error_tag(symbol->errtxt, error_number); error_tag(symbol->errtxt, error_number);