Skip to content

Commit 74a7ac1

Browse files
committed
[silicon_creator,cert] Fix unittest
The code is technically incorrect: for an empty vector, accessing the first element is undefined behaviour and this can abort if the c++ library is compiled with assertions. On the other hand, data() is well-defined for an empty vector (it just cannot be dereferenced). Signed-off-by: Amaury Pouly <[email protected]>
1 parent 39f3281 commit 74a7ac1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sw/device/silicon_creator/lib/cert/asn1_unittest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ TEST(Asn1, TagLengthEncoding) {
461461
asn1_tag_t tag; \
462462
asn1_start_tag(&state, &tag, kAsn1TagNumberSequence); \
463463
EXPECT_EQ(state.error, kErrorOk); \
464-
asn1_push_bytes(&state, &tmp[0], tmp.size()); \
464+
asn1_push_bytes(&state, tmp.data(), tmp.size()); \
465465
EXPECT_EQ(state.error, kErrorOk); \
466466
asn1_finish_tag(&tag); \
467467
EXPECT_EQ(state.error, kErrorOk); \

0 commit comments

Comments
 (0)