Skip to content

Commit 905c430

Browse files
nordic-krchcfriedt
authored andcommitted
tests: lib: cbprintf_package: Fix coverity issue
Ensure that length variables (len0, len1, len2) are positive before they are used for array indexing. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
1 parent b942aab commit 905c430

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/lib/cbprintf_package/src/test.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,15 @@ void test_cbprintf_rw_str_indexes(void)
148148
ztest_test_skip();
149149
}
150150

151+
zassert_true(len0 > 0, NULL);
151152
len1 = cbprintf_package(NULL, 0, CBPRINTF_PACKAGE_ADD_STRING_IDXS,
152153
test_str, 100, test_str1);
154+
zassert_true(len1 > 0, NULL);
155+
153156
CBPRINTF_STATIC_PACKAGE(NULL, 0, len2, 0,
154157
CBPRINTF_PACKAGE_ADD_STRING_IDXS,
155158
test_str, 100, test_str1);
159+
zassert_true(len2 > 0, NULL);
156160

157161
/* package with string indexes will contain two more bytes holding indexes
158162
* of string parameter locations.

0 commit comments

Comments
 (0)