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

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 04:50:12 PDT 2020


labath marked 2 inline comments as done.
labath added inline comments.


================
Comment at: llvm/include/llvm/Support/LEB128.h:137
   do {
-    if (end && p == end) {
+    if (p == end) {
       if (error)
----------------
dblaikie wrote:
> 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.
Sounds good. I'll try to create a patch for that.


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