[clang] [clang][Sema] Fix over-read when scanf format ends with field width (PR #227716)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 18:04:02 PDT 2026


================
@@ -131,12 +131,12 @@ static ScanfSpecifierResult ParseScanfSpecifier(FormatStringHandler &H,
   if (Amt.getHowSpecified() != OptionalAmount::NotSpecified) {
     assert(Amt.getHowSpecified() == OptionalAmount::Constant);
     FS.setFieldWidth(Amt);
+  }
 
-    if (I == E) {
-      // No more characters left?
-      H.HandleIncompleteSpecifier(Start, E - Start);
-      return true;
-    }
+  if (I == E) {
+    // No more characters left?
----------------
shafik wrote:

Nitpick, but I don't think this is a question, we know there are no more characters left, right? I think the comment should go before the `if` statement. 

https://github.com/llvm/llvm-project/pull/227716


More information about the cfe-commits mailing list