From 8319f159ac86ed009a73b6bdb1dd9c1822fbc677 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 30 Jun 2023 02:53:08 -0700 Subject: [PATCH] CheckWriteRead should fail if payloadBase38Representation fails to parse the QRCode (#27554) * CheckWriteRead should fail if payloadBase38Representation fails to parse the QRCode * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/setup_payload/tests/TestHelpers.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/setup_payload/tests/TestHelpers.h b/src/setup_payload/tests/TestHelpers.h index 8d84791e8b103a..dedd9040ae205e 100644 --- a/src/setup_payload/tests/TestHelpers.h +++ b/src/setup_payload/tests/TestHelpers.h @@ -141,7 +141,12 @@ inline bool CheckWriteRead(SetupPayload & inPayload, bool allowInvalidPayload = memset(optionalInfo, 0xFF, sizeof(optionalInfo)); auto generator = QRCodeSetupPayloadGenerator(inPayload); generator.SetAllowInvalidPayload(allowInvalidPayload); - generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo)); + CHIP_ERROR err = generator.payloadBase38Representation(result, optionalInfo, sizeof(optionalInfo)); + + if (err != CHIP_NO_ERROR) + { + return false; + } outPayload = {}; QRCodeSetupPayloadParser(result).populatePayload(outPayload);