Fix global overflow in types::lookupTypeForTypeSpecifier.

memcpy() is allowed to read entire contents of both memory areas.

Found with AddressSanitizer.

llvm-svn: 176237
This commit is contained in:
Evgeniy Stepanov 2013-02-28 07:53:32 +00:00
parent 1052c99f46
commit 00eef441ff
1 changed files with 1 additions and 3 deletions

View File

@ -168,12 +168,10 @@ types::ID types::lookupTypeForExtension(const char *Ext) {
}
types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
unsigned N = strlen(Name);
for (unsigned i=0; i<numTypes; ++i) {
types::ID Id = (types::ID) (i + 1);
if (canTypeBeUserSpecified(Id) &&
memcmp(Name, getInfo(Id).Name, N + 1) == 0)
strcmp(Name, getInfo(Id).Name) == 0)
return Id;
}