From: Eli Friedman Date: Tue, 11 Sep 2012 00:36:26 +0000 (+0000) Subject: Fix buffer overflow. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=116bb09882bc1c9281cd84dd07496201feb18d18;p=clang Fix buffer overflow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163578 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CommentCommandTraits.cpp b/lib/AST/CommentCommandTraits.cpp index 26e2dee3a2..ba0aa9ae12 100644 --- a/lib/AST/CommentCommandTraits.cpp +++ b/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();