Fix buffer overflow.

llvm-svn: 163578
This commit is contained in:
Eli Friedman 2012-09-11 00:36:26 +00:00
parent 12f669e3cd
commit de4f470125
1 changed files with 2 additions and 2 deletions

View File

@ -32,9 +32,9 @@ const CommandInfo *CommandTraits::getCommandInfo(unsigned CommandID) const {
}
const CommandInfo *CommandTraits::registerUnknownCommand(StringRef CommandName) {
char *Name = Allocator.Allocate<char>(CommandName.size());
char *Name = Allocator.Allocate<char>(CommandName.size() + 1);
memcpy(Name, CommandName.data(), CommandName.size());
Name[CommandName.size() + 1] = '\0';
Name[CommandName.size()] = '\0';
// Value-initialize (=zero-initialize in this case) a new CommandInfo.
CommandInfo *Info = new (Allocator) CommandInfo();