From de4f4701259c3b87736343fa88a3b0cd02350afd Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 11 Sep 2012 00:36:26 +0000 Subject: [PATCH] Fix buffer overflow. llvm-svn: 163578 --- clang/lib/AST/CommentCommandTraits.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp index 26e2dee3a26f..ba0aa9ae12ef 100644 --- a/clang/lib/AST/CommentCommandTraits.cpp +++ b/clang/lib/AST/CommentCommandTraits.cpp @@ -32,9 +32,9 @@ const CommandInfo *CommandTraits::getCommandInfo(unsigned CommandID) const { } const CommandInfo *CommandTraits::registerUnknownCommand(StringRef CommandName) { - char *Name = Allocator.Allocate(CommandName.size()); + char *Name = Allocator.Allocate(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();