[PATCH] D114342: ConvertUTF, new wrapper API

Aaron Ballman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 25 05:35:37 PST 2022


aaron.ballman added inline comments.


================
Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:148
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+    return true;
----------------
cor3ntin wrote:
> 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
I'm happy with the alignment assertion, but I was asking for `assert(SrcBytes.size() % sizeof(UTF32) == 0);` to ensure nobody does something silly like pass in 13 bytes of data and expect good things to happen.


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

https://reviews.llvm.org/D114342



More information about the llvm-commits mailing list