Avoid segfault generating DataBar Stacked

Do not read element values which have not been initialised when stacking symbol
Fixes #6
This commit is contained in:
Robin Stuart 2016-01-10 13:24:25 +00:00
parent bfb3964fc0
commit 27c7c9447c

View File

@ -2121,9 +2121,11 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
left_to_right = 1; left_to_right = 1;
i = 2 + (current_block * 21); i = 2 + (current_block * 21);
for(j = 0; j < 21; j++) { for(j = 0; j < 21; j++) {
if((i + j) < pattern_width) {
sub_elements[j + (reader * 21) + 2] = elements[i + j]; sub_elements[j + (reader * 21) + 2] = elements[i + j];
elements_in_sub++; elements_in_sub++;
} }
}
} else { } else {
/* right to left */ /* right to left */
left_to_right = 0; left_to_right = 0;
@ -2131,20 +2133,24 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
/* a full row */ /* a full row */
i = 2 + (((current_row * symbol->option_2) - reader - 1) * 21); i = 2 + (((current_row * symbol->option_2) - reader - 1) * 21);
for(j = 0; j < 21; j++) { for(j = 0; j < 21; j++) {
if((i + j) < pattern_width) {
sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j]; sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j];
elements_in_sub++; elements_in_sub++;
} }
}
} else { } else {
/* a partial row */ /* a partial row */
k = ((current_row * symbol->option_2) - codeblocks); k = ((current_row * symbol->option_2) - codeblocks);
l = (current_row * symbol->option_2) - reader - 1; l = (current_row * symbol->option_2) - reader - 1;
i = 2 + ((l - k) * 21); i = 2 + ((l - k) * 21);
for(j = 0; j < 21; j++) { for(j = 0; j < 21; j++) {
if((i + j) < pattern_width) {
sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j]; sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j];
elements_in_sub++; elements_in_sub++;
} }
} }
} }
}
reader++; reader++;
current_block++; current_block++;
} while ((reader < symbol->option_2) && (current_block < codeblocks)); } while ((reader < symbol->option_2) && (current_block < codeblocks));