From: Vsevolod Stakhov Date: Thu, 5 Feb 2026 14:04:57 +0000 (+0000) Subject: [Fix] clang-plugin: add null check for struct type in check_struct_type X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e02ee6b498825474c9f777f0427b98d98eb7185;p=thirdparty%2Frspamd.git [Fix] clang-plugin: add null check for struct type in check_struct_type --- diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc index 39c6b2c8e2..bba4e83673 100644 --- a/clang-plugin/printf_check.cc +++ b/clang-plugin/printf_check.cc @@ -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();