Ensure ECI encoding doesn't corrupt binary data in Data Matrix

Fixes #105 reported by Daniel Gredler
This commit is contained in:
Robin Stuart 2018-06-20 23:47:06 +01:00
parent 8fcde380f8
commit 23a990c37c

View File

@ -581,12 +581,14 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
if (symbol->eci <= 126) {
target[tp] = (unsigned char) symbol->eci + 1;
tp++;
strcat(binary, " ");
}
if ((symbol->eci >= 127) && (symbol->eci <= 16382)) {
target[tp] = (unsigned char) ((symbol->eci - 127) / 254) + 128;
tp++;
target[tp] = (unsigned char) ((symbol->eci - 127) % 254) + 1;
tp++;
strcat(binary, " ");
}
if (symbol->eci >= 16383) {
target[tp] = (unsigned char) ((symbol->eci - 16383) / 64516) + 192;
@ -595,6 +597,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
tp++;
target[tp] = (unsigned char) ((symbol->eci - 16383) % 254) + 1;
tp++;
strcat(binary, " ");
}
if (debug) printf("ECI %d ", symbol->eci + 1);
}