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,8 +2121,10 @@ 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++) {
sub_elements[j + (reader * 21) + 2] = elements[i + j]; if((i + j) < pattern_width) {
elements_in_sub++; sub_elements[j + (reader * 21) + 2] = elements[i + j];
elements_in_sub++;
}
} }
} else { } else {
/* right to left */ /* right to left */
@ -2131,8 +2133,10 @@ 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++) {
sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j]; if((i + j) < pattern_width) {
elements_in_sub++; sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j];
elements_in_sub++;
}
} }
} else { } else {
/* a partial row */ /* a partial row */
@ -2140,8 +2144,10 @@ int rssexpanded(struct zint_symbol *symbol, unsigned char source[], int src_len)
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++) {
sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j]; if((i + j) < pattern_width) {
elements_in_sub++; sub_elements[(20 - j) + (reader * 21) + 2] = elements[i + j];
elements_in_sub++;
}
} }
} }
} }