Commit c3a1cd78 authored by Igor Sugak's avatar Igor Sugak Committed by Facebook Github Bot

fix invalid-null-argument UBSAN error in IOBufQueue.cpp

Summary:
UndefinedBehaviorSanitizer: invalid-null-argument folly/io/IOBufQueue.cpp:53:38
```

Add a check that the length is greater than zero.

Reviewed By: meyering

Differential Revision: D7139027

fbshipit-source-id: 37585092429af52d14c98c193ecc495752bbda1c
parent 2b4a5c9a
......@@ -47,9 +47,8 @@ appendToChain(unique_ptr<IOBuf>& dst, unique_ptr<IOBuf>&& src, bool pack) {
// joining two IOBufQueues together.
size_t copyRemaining = MAX_PACK_COPY;
uint64_t n;
while (src &&
(n = src->length()) < copyRemaining &&
n < tail->tailroom()) {
while (src && (n = src->length()) < copyRemaining &&
n < tail->tailroom() && n > 0) {
memcpy(tail->writableTail(), src->data(), n);
tail->append(n);
copyRemaining -= n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment