[PATCH] D114342: ConvertUTF, new wrapper API

Corentin Jabot via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 04:18:05 PST 2022


cor3ntin added inline comments.


================
Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:148
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+    return true;
----------------
aaron.ballman wrote:
> Bigcheese wrote:
> > I believe this actually needs an additional check that that `SrcBytes.size()` is `< 4` and return false.
> Should we be testing that the input array length is a multiple of 4 as well?
There is an assert just below, I suppose that's fine


================
Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:163
+    Src = &ByteSwapped[0];
+    SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1;
+  }
----------------
`SrcEnd = Src + ByteSwapped.size()` may be easier to read.


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

https://reviews.llvm.org/D114342



More information about the llvm-commits mailing list