[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

Sindhu Chittireddy via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 2 13:28:07 PST 2022


schittir updated this revision to Diff 479731.
schittir added a comment.

Add assert instead of multiple checks in if conditions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139148/new/

https://reviews.llvm.org/D139148

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5827,6 +5827,8 @@
     return;
   }
 
+  assert(Initializer && "Intializer must be non-null");
+
   //     - If the destination type is an array of characters, an array of
   //       char16_t, an array of char32_t, or an array of wchar_t, and the
   //       initializer is a string literal, see 8.5.2.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139148.479731.patch
Type: text/x-patch
Size: 475 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221202/035f01e5/attachment.bin>


More information about the cfe-commits mailing list