[lld] r238669 - Fix unsafe memory access.

Rui Ueyama ruiu at google.com
Sun May 31 09:14:57 PDT 2015


Thanks. Addressed in r238675.

On Sat, May 30, 2015 at 10:10 PM, Simon Atanasyan <simon at atanasyan.com>
wrote:

> Hi,
>
> On Sun, May 31, 2015 at 6:57 AM, Rui Ueyama <ruiu at google.com> wrote:
> > @@ -172,7 +174,7 @@ ErrorOr<StringRef> SymbolTable::findDefa
> >        {"WinMain", "WinMainCRTStartup"},
> >        {"wWinMain", "wWinMainCRTStartup"},
> >    };
> > -  for (size_t I = 0; I < sizeof(Entries); ++I) {
> > +  for (size_t I = 0; I < array_lengthof(Entries); ++I) {
> >      if (!find(Entries[I][0]))
> >        continue;
> >      if (auto EC = addSymbol(new Undefined(Entries[I][1])))
>
> Maybe the range loop based approach is even safer and shorter:
> [[
> for (const auto &Entry : Entries) {
>   if (!find(Entry[0]))
>     continue;
>   if (auto EC = addSymbol(new Undefined(Entry[1])))
>     return EC;
>   return StringRef(Entry[1]);
> }
> ]]
>
> --
> Simon Atanasyan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150531/c8a7685a/attachment.html>


More information about the llvm-commits mailing list