wasphin commented on code in PR #3661:
URL: https://github.com/apache/brpc/pull/3661#discussion_r4578263385


##########
test/CMakeLists.txt:
##########
@@ -88,6 +88,7 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/run_tests.sh 
DESTINATION ${CMAKE_CURRENT_B
 SET(TEST_BUTIL_SOURCES
     ${CMAKE_CURRENT_SOURCE_DIR}/abalist_unittest.cc
     ${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory_unittest.cc
+    ${CMAKE_CURRENT_SOURCE_DIR}/arena_unittest.cc

Review Comment:
   Fixed in dcb0d354: arena_unittest.cc is now included in TEST_BUTIL_SOURCES 
in test/Makefile. Both existing ArenaTest cases passed when compiled and run 
directly with Clang. The full Make suite was not rerun locally.



##########
src/butil/arena.cpp:
##########
@@ -64,7 +64,13 @@ void Arena::clear() {
 }
 
 void* Arena::allocate_new_block(size_t n) {
+    if (n > UINT32_MAX || n > SIZE_MAX - offsetof(Block, data)) {
+        return nullptr;
+    }
     Block* b = (Block*)malloc(offsetof(Block, data) + n);
+    if (b == nullptr) {
+        return nullptr;

Review Comment:
   Agreed: the existing tests exercise representability bounds and continued 
usability, not a representable allocation returning null from malloc. They 
would not detect removal of that null check. We are retaining that coverage 
boundary rather than introducing allocator injection, allocator interposition 
or process resource limits solely to exercise this guard. Actual malloc-failure 
handling is checked by inspection; no deterministic OOM coverage is claimed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to