[PATCH] D77304: [llvm/Support] Don't crash on empty nullptr ranges when decoding LEBs

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 16:17:53 PDT 2020


dblaikie accepted this revision.
dblaikie added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/include/llvm/Support/LEB128.h:137
   do {
-    if (end && p == end) {
+    if (p == end) {
       if (error)
----------------
Is it possible this functionality originally existed for accepting unbounded buffers? (like the classic unix `gets` function) by passing nullptr as the end bound it'd just keep reading from the buffer until it decoded a ULEB128?

While such functionality would be pretty problematic from a memory safety perspective - worth checking if any users might be relying on that? I guess it's more likely this was just copied in from somewhere else/some example implementation and retained the "Bonus" functionality without it being intentional, an if all the tests pass I'm fine removing this quirk/feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77304





More information about the llvm-commits mailing list