Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions common/iovector.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,13 @@ class iovector
update(va);
return ptr;
}

if (va.sum() < bytes) {
return nullptr;
}

auto buf = do_malloc(bytes);
auto ret = extract_front(bytes, buf);
return ret == bytes ?
buf :
nullptr;
extract_front(bytes, buf);
return buf;
}

// try to extract `bytes` bytes from the back
Expand Down Expand Up @@ -618,12 +619,13 @@ class iovector
update(va);
return ptr;
}
if (va.sum() < bytes) {
return nullptr;
}

auto buf = do_malloc(bytes);
auto ret = extract_back(bytes, buf);
return ret == bytes ?
buf :
nullptr;
extract_back(bytes, buf);
return buf;
}

// copy data to a buffer of size `size`,
Expand Down Expand Up @@ -1080,4 +1082,4 @@ class SmartCloneIOV

#undef IF_ASSERT_RETURN

#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
Loading