[clang] Fix Unintialised char *CommentLexer resulting in potential UB. (PR #210067)

Hardik Kumar via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 16 07:21:47 PDT 2026


https://github.com/hardikxk created https://github.com/llvm/llvm-project/pull/210067

The patch intialised the  pointer to a .
Previously the pointer would have some garbage value which might have resulted in UB.

closes #210034

>From 786456a6a0b4ab822889bc74bb7b1585bd3f038d Mon Sep 17 00:00:00 2001
From: hardikxk <hardikxk at gmail.com>
Date: Thu, 16 Jul 2026 19:50:38 +0530
Subject: [PATCH] Fix Unintialised char *CommentLexer resulting in potential
 UB.

The patch intialised the  pointer to a .
Previously the pointer would have some garbage value which might have resulted in UB.

closes #210034
---
 clang/include/clang/AST/CommentLexer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/CommentLexer.h b/clang/include/clang/AST/CommentLexer.h
index 194a31cb7b934..7e224f4d4cfb2 100644
--- a/clang/include/clang/AST/CommentLexer.h
+++ b/clang/include/clang/AST/CommentLexer.h
@@ -240,7 +240,7 @@ class Lexer {
 
   /// One past end pointer for the current comment.  For BCPL comments points
   /// to newline or BufferEnd, for C comments points to star in '*/'.
-  const char *CommentEnd;
+  const char *CommentEnd{nullptr};
 
   SourceLocation FileLoc;
 



More information about the cfe-commits mailing list