]> granicus.if.org Git - clang/commitdiff
Fix off-by-one error in ParseFormatSpecifier() when reporting the location of a null...
authorTed Kremenek <kremenek@apple.com>
Thu, 28 Jan 2010 23:56:52 +0000 (23:56 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 28 Jan 2010 23:56:52 +0000 (23:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94762 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PrintfFormatString.cpp

index 544956ac411b265e239e87c0e311d7f6545a1f2c..986411fc7d2b637e53df61c6542ce4beba6a43c3 100644 (file)
@@ -89,16 +89,15 @@ static FormatSpecifierResult ParseFormatSpecifier(FormatStringHandler &H,
   UpdateOnReturn <const char*> UpdateBeg(Beg, I);
 
   // Look for a '%' character that indicates the start of a format specifier.
-  while (I != E) {
+  for ( ; I != E ; ++I) {
     char c = *I;
-    ++I;    
     if (c == '\0') {
       // Detect spurious null characters, which are likely errors.
       H.HandleNullChar(I);
       return true;
     }
     if (c == '%') {
-      Start = I;  // Record the start of the format specifier.
+      Start = I++;  // Record the start of the format specifier.
       break;
     }
   }