lib: os: cbprintf_packaged: Fix cbprintf_package_convert
When conversion is done in two steps (output length calculation followed by the actual conversion), it was failing when helper array for holding calculated string length from the first conversion run was shorter than number of strings that were supposed to be appended to the package. Fix by taking into account strl_len to determine if length can be taken from the array or need to be calculated again. Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
f82ffc9213
commit
3bf54a9e85
1 changed files with 1 additions and 1 deletions
|
@ -1148,7 +1148,7 @@ calculate_string_length:
|
|||
for (unsigned int i = 0; i < scpy_cnt; i++) {
|
||||
uint8_t loc = cpy_str_pos[i];
|
||||
const char *str = *(const char **)&buf32[loc];
|
||||
uint16_t str_len = strl ? strl[i] : 0;
|
||||
uint16_t str_len = (strl && (i < strl_len)) ? strl[i] : 0;
|
||||
|
||||
rv = cb(&loc, 1, ctx);
|
||||
if (rv < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue