else if (Str[0] >= '0' && Str[0] <= '9') // 52..61
CharVal = Str[0] - '0' + 52;
else if (Str[0] == '+') // 62
- CharVal = Str[0] - '+' + 62;
+ CharVal = 62;
else if (Str[0] == '/') // 63
- CharVal = Str[0] - '/' + 63;
+ CharVal = 63;
else
return true;
getObject(StringTable, Data, StringTableAddr, StringTableSize))
return EC;
+ // Treat table sizes < 4 as empty because contrary to the PECOFF spec, some
+ // tools like cvtres write a size of 0 for an empty table instead of 4.
+ if (StringTableSize < 4)
+ StringTableSize = 4;
+
// Check that the string table is null terminated if has any in it.
- if (StringTableSize < 4 ||
- (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0))
+ if (StringTableSize > 4 && StringTable[StringTableSize - 1] != 0)
return object_error::parse_failed;
return object_error::success;
}
ErrorOr<ObjectFile *> ObjectFile::createCOFFObjectFile(MemoryBuffer *Object,
bool BufferOwned) {
error_code EC;
- OwningPtr<COFFObjectFile> Ret(new COFFObjectFile(Object, EC, BufferOwned));
+ std::unique_ptr<COFFObjectFile> Ret(
+ new COFFObjectFile(Object, EC, BufferOwned));
if (EC)
return EC;
- return Ret.take();
+ return Ret.release();
}