DPD: fix no terminating NUL (required by c128_cost()), regression

introduced by last commit [fef8b0], and only picked up in a
  fairly random test on the mac build :(
This commit is contained in:
gitlost 2025-02-16 00:53:29 +00:00
parent fef8b083b4
commit f9878700ee
2 changed files with 4 additions and 4 deletions

View file

@ -236,6 +236,7 @@ static int c128_set_values(const unsigned char source[], const int length, const
memset(costs, 0, sizeof(*costs) * length); memset(costs, 0, sizeof(*costs) * length);
assert(source[length] == '\0'); /* Terminating NUL required by `c128_cost()` */
c128_cost(source, length, 0 /*i*/, 0 /*prior_cset*/, start_idx, priority, fncs, manuals, costs, modes); c128_cost(source, length, 0 /*i*/, 0 /*prior_cset*/, start_idx, priority, fncs, manuals, costs, modes);
if (costs[0][0] > C128_SYMBOL_MAX) { /* Total minimal cost (glyph count) */ if (costs[0][0] > C128_SYMBOL_MAX) { /* Total minimal cost (glyph count) */

View file

@ -67,7 +67,7 @@ static int nve18_or_ean14(struct zint_symbol *symbol, unsigned char source[], co
memcpy(ean128_equiv + 4 + zeroes, source, length); memcpy(ean128_equiv + 4 + zeroes, source, length);
ean128_equiv[data_len + 4] = gs1_check_digit(ean128_equiv + 4, data_len); ean128_equiv[data_len + 4] = gs1_check_digit(ean128_equiv + 4, data_len);
ean128_equiv[data_len + 5] = '\0'; ean128_equiv[data_len + 5] = '\0'; /* Terminating NUL required by `c128_cost()` */
error_number = gs1_128(symbol, ean128_equiv, data_len + 5); error_number = gs1_128(symbol, ean128_equiv, data_len + 5);
@ -112,9 +112,8 @@ INTERNAL int dpd(struct zint_symbol *symbol, unsigned char source[], int length)
if (length == 27 && !relabel) { if (length == 27 && !relabel) {
local_source_buf[0] = '%'; local_source_buf[0] = '%';
memcpy(local_source_buf + 1, source, length); memcpy(local_source_buf + 1, source, ++length); /* Include terminating NUL (required by `c128_cost()`) */
local_source = local_source_buf; local_source = local_source_buf;
length++;
} else { } else {
local_source = source; local_source = source;
} }
@ -271,7 +270,7 @@ INTERNAL int upu_s10(struct zint_symbol *symbol, unsigned char source[], int len
local_source[12] = local_source[11]; local_source[12] = local_source[11];
local_source[11] = local_source[10]; local_source[11] = local_source[10];
local_source[10] = itoc(check_digit); local_source[10] = itoc(check_digit);
local_source[13] = '\0'; local_source[13] = '\0'; /* Terminating NUL required by `c128_cost()` */
/* Do some checks on the Service Indicator (first char only) and Country Code */ /* Do some checks on the Service Indicator (first char only) and Country Code */
if (strchr("JKSTW", local_source[0]) != NULL) { /* These are reserved & cannot be assigned */ if (strchr("JKSTW", local_source[0]) != NULL) { /* These are reserved & cannot be assigned */