[cfe-commits] r163578 - /cfe/trunk/lib/AST/CommentCommandTraits.cpp

Eli Friedman eli.friedman at gmail.com
Mon Sep 10 17:36:27 PDT 2012


Author: efriedma
Date: Mon Sep 10 19:36:26 2012
New Revision: 163578

URL: http://llvm.org/viewvc/llvm-project?rev=163578&view=rev
Log:
Fix buffer overflow.


Modified:
    cfe/trunk/lib/AST/CommentCommandTraits.cpp

Modified: cfe/trunk/lib/AST/CommentCommandTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentCommandTraits.cpp?rev=163578&r1=163577&r2=163578&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentCommandTraits.cpp (original)
+++ cfe/trunk/lib/AST/CommentCommandTraits.cpp Mon Sep 10 19:36:26 2012
@@ -32,9 +32,9 @@
 }
 
 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();





More information about the cfe-commits mailing list