[PATCH] D63789: [ODRHash] Fix null pointer dereference for ObjC selectors with empty slots.
Richard Trieu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 25 18:45:44 PDT 2019
rtrieu added inline comments.
================
Comment at: clang/lib/AST/ODRHash.cpp:73
AddBoolean(S.isUnarySelector());
unsigned NumArgs = S.getNumArgs();
for (unsigned i = 0; i < NumArgs; ++i) {
----------------
There's actually a second bug here as well. When processing an arbitrary number of elements, the number of elements needs to placed before the list. This line should be added before the for-loop:
```
ID.AddInteger(NumArgs);
```
This change isn't directly related to your original patch, so feel free to skip it.
================
Comment at: clang/lib/AST/ODRHash.cpp:75
for (unsigned i = 0; i < NumArgs; ++i) {
- AddIdentifierInfo(S.getIdentifierInfoForSlot(i));
+ ID.AddString(S.getNameForSlot(i));
}
----------------
For possibly null pointers, ODRHash uses a boolean before processing the pointer. The way to fix this is:
```
const IdentifierInfo *II = S.getIdentifierInfoForSlot(i);
AddBoolean(II)
if (II) {
AddIdentifierInfo(II);
}
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63789/new/
https://reviews.llvm.org/D63789
More information about the cfe-commits
mailing list