Skip to content

Commit

Permalink
bdlbb_blobstreambuf: fix ubsan (#4956)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalawawa authored and GitHub Enterprise committed Sep 17, 2024
1 parent 01fbfc1 commit f4d1b6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions groups/bdl/bdlbb/bdlbb_blobstreambuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,11 @@ bsl::streamsize InBlobStreamBuf::xsgetn(char_type *destination,
bsl::streamsize remainingChars = egptr() - gptr();
bsl::streamsize canCopy = bsl::min(remainingChars, numLeft);

bsl::memcpy(destination + numCopied, gptr(), canCopy);
gbump(static_cast<int>(canCopy));
numLeft -= canCopy;
if (0 < canCopy) {
bsl::memcpy(destination + numCopied, gptr(), canCopy);
gbump(static_cast<int>(canCopy));
numLeft -= canCopy;
}

if (0 < numLeft && gptr() == egptr() &&
traits_type::eof() == underflow()) {
Expand Down

0 comments on commit f4d1b6e

Please sign in to comment.