[libc-commits] [PATCH] D150529: [libc] Make the bump pointer explicitly return null on buffer oveerrun

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon May 15 04:15:06 PDT 2023


jhuber6 marked 3 inline comments as done.
jhuber6 added inline comments.


================
Comment at: libc/test/IntegrationTest/test.cpp:69
   ptr += s;
-  return mem;
+  return static_cast<uint64_t>(ptr - memory) >= memory_size ? nullptr : mem;
 }
----------------
sivachandra wrote:
> s/`uint64_t`/`ptrdiff_t`?
The size is unsigned so we'll get warnings about the comparison. Since we know `ptr >= memory` we know that this will never be negative.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150529/new/

https://reviews.llvm.org/D150529



More information about the libc-commits mailing list