mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add unlatch if C40/Text buffer is empty
also don't read binary marker beyond end of input Relates to #38 and #41
This commit is contained in:
parent
a0493a0d0c
commit
886e789090
@ -944,7 +944,7 @@ static int dm200encode(struct zint_symbol *symbol, const unsigned char source[],
|
|||||||
/* start of binary data */
|
/* start of binary data */
|
||||||
int binary_count; /* length of b256 data */
|
int binary_count; /* length of b256 data */
|
||||||
|
|
||||||
for (binary_count = 0; binary[binary_count + i] == 'b'; binary_count++);
|
for (binary_count = 0; binary_count + i < tp && binary[binary_count + i] == 'b'; binary_count++);
|
||||||
|
|
||||||
if (binary_count <= 249) {
|
if (binary_count <= 249) {
|
||||||
dminsert(binary, i, 'b');
|
dminsert(binary, i, 'b');
|
||||||
@ -995,9 +995,7 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
|
|||||||
}
|
}
|
||||||
target[target_length] = source[inputlen - 1] + 1;
|
target[target_length] = source[inputlen - 1] + 1;
|
||||||
target_length++;
|
target_length++;
|
||||||
}
|
} else if (process_p == 2) // 2 data characters left to encode.
|
||||||
|
|
||||||
if (process_p == 2) // 2 data characters left to encode.
|
|
||||||
{
|
{
|
||||||
// Pad with shift 1 value (0) and encode as double.
|
// Pad with shift 1 value (0) and encode as double.
|
||||||
int intValue = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + 1; // ie (0 + 1).
|
int intValue = (1600 * process_buffer[0]) + (40 * process_buffer[1]) + 1; // ie (0 + 1).
|
||||||
@ -1009,6 +1007,11 @@ static int dm200encode_remainder(unsigned char target[], int target_length, cons
|
|||||||
target[target_length] = 254; // Unlatch
|
target[target_length] = 254; // Unlatch
|
||||||
target_length++;
|
target_length++;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (symbols_left > 0) {
|
||||||
|
target[target_length] = 254; // Unlatch
|
||||||
|
target_length++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user