This is an archive of the discontinued LLVM Phabricator instance.

[lsan] [NFC] Change ARRAY_SIZE to internal_strnlen
ClosedPublic

Authored by george.karpenkov on Nov 13 2018, 11:47 AM.

Details

Summary

Calling ARRAY_SIZE on a char* will not actually compute it's size, but just the pointer size.
A new Clang warning enables by default warns about this.

Replaced the call with internal_strnlen.

Diff Detail

Repository
rL LLVM

Event Timeline

fjricci accepted this revision.Nov 13 2018, 11:49 AM

lgtm - thanks!

This revision is now accepted and ready to land.Nov 13 2018, 11:49 AM
This revision was automatically updated to reflect the committed changes.

@fjricci Now the test is actually failing, because the size of e.g. "__objc_classlist" is 16, and kMaxSegName is also 16. I'm changing < to <=, and adding +1 to the second strnlen arguments.
(unless there are any objections)

I think that should be fine?