summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/CommentCommandTraits.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-09-11 00:36:26 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-09-11 00:36:26 +0000
commitde4f4701259c3b87736343fa88a3b0cd02350afd (patch)
tree6064e1ac3335866071f493779eca52b16059e2e4 /clang/lib/AST/CommentCommandTraits.cpp
parent12f669e3cd42b20eb3abd1e1a43b2fd9c7d8a923 (diff)
downloadbcm5719-llvm-de4f4701259c3b87736343fa88a3b0cd02350afd.tar.gz
bcm5719-llvm-de4f4701259c3b87736343fa88a3b0cd02350afd.zip
Fix buffer overflow.
llvm-svn: 163578
Diffstat (limited to 'clang/lib/AST/CommentCommandTraits.cpp')
-rw-r--r--clang/lib/AST/CommentCommandTraits.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/AST/CommentCommandTraits.cpp b/clang/lib/AST/CommentCommandTraits.cpp
index 26e2dee3a26..ba0aa9ae12e 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<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();
OpenPOWER on IntegriCloud