Skip to content

Commit

Permalink
[setup_payload] Fixed bug with not reducing span size properly (#18598)
Browse files Browse the repository at this point in the history
Output buffer span is not reduced properly, as subspan is
passed to the base38Encode method and changed size doesn't
propagate to the outBuffer.

Added reducing outBuffer size to the subSpan + prefixLen size.
  • Loading branch information
kkasperczyk-no authored and pull[bot] committed Jun 24, 2022
1 parent a85289e commit 4292483
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/setup_payload/QRCodeSetupPayloadGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ static CHIP_ERROR payloadBase38RepresentationWithTLV(PayloadContents & payload,
MutableCharSpan subSpan = outBuffer.SubSpan(prefixLen, outBuffer.size() - prefixLen);
memcpy(outBuffer.data(), kQRCodePrefix, prefixLen);
err = base38Encode(bits, subSpan);
// Reduce output span size to be the size of written data
outBuffer.reduce_size(subSpan.size() + prefixLen);
}

return err;
Expand Down

0 comments on commit 4292483

Please sign in to comment.