1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-17 18:07:02 +00:00

library: move check for valid UTF-8 after de-escaping

CODE128: fix bad index 0 -> i in `c128_glyph_count()`
This commit is contained in:
gitlost
2024-10-30 16:37:42 +00:00
parent 7e6da28761
commit 71b2dc50b7
5 changed files with 51 additions and 49 deletions

View File

@@ -1161,14 +1161,6 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
}
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
for (i = 0; i < seg_count; i++) {
if (!is_valid_utf8(local_segs[i].source, local_segs[i].length)) {
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 245, "Invalid UTF-8 in input");
}
}
}
local_sources = (unsigned char *) z_alloca(total_len + seg_count);
/* Copy input, de-escaping if required */
@@ -1199,6 +1191,11 @@ int ZBarcode_Encode_Segs(struct zint_symbol *symbol, const struct zint_seg segs[
}
if ((symbol->input_mode & 0x07) == UNICODE_MODE) {
for (i = 0; i < seg_count; i++) {
if (!is_valid_utf8(local_segs[i].source, local_segs[i].length)) {
return error_tag(ZINT_ERROR_INVALID_DATA, symbol, 245, "Invalid UTF-8 in input");
}
}
/* Only strip BOM on first segment */
strip_bom(local_segs[0].source, &local_segs[0].length);
}