]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] clang-plugin: add null check for struct type in check_struct_type
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 14:04:57 +0000 (14:04 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 14:04:57 +0000 (14:04 +0000)
clang-plugin/printf_check.cc

index 39c6b2c8e201d4e02ae404211a121611304b769a..bba4e83673628cbdb9affc88ac0c52df120ddd6b 100644 (file)
@@ -764,6 +764,14 @@ check_struct_type(const Expr *arg, struct PrintfArgChecker *ctx,
        }
 
        auto struct_type = desugared_type->getAsStructureType();
+       if (!struct_type) {
+               /* Could be a C++ class or union, not a struct */
+               auto err_msg = std::string("not a struct type for ") + fmt + " arg: " +
+                                          arg->getType().getAsString();
+               print_error(err_msg.c_str(),
+                                       arg, ctx->past, ctx->pci);
+               return false;
+       }
        auto struct_decl = struct_type->getDecl();
        auto struct_def = struct_decl->getNameAsString();