From a9b5cf99f7b6187c7af5488f253e278c9a6d2baf Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 7 Apr 2023 11:53:19 +0200 Subject: [PATCH] UBSAN: Add __ubsan_handle_nonnull_arg --- libluna/include/luna/UBSAN.h | 6 ++++++ libluna/src/UBSAN.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libluna/include/luna/UBSAN.h b/libluna/include/luna/UBSAN.h index 2e9202f5..dce0c9f1 100644 --- a/libluna/include/luna/UBSAN.h +++ b/libluna/include/luna/UBSAN.h @@ -70,5 +70,11 @@ namespace UBSAN { SourceLocation location; }; + + struct NonnullArgInfo + { + SourceLocation location; + SourceLocation attr_location; + }; } } diff --git a/libluna/src/UBSAN.cpp b/libluna/src/UBSAN.cpp index 4f3c25d2..46bf2059 100644 --- a/libluna/src/UBSAN.cpp +++ b/libluna/src/UBSAN.cpp @@ -118,4 +118,10 @@ extern "C" }; __ubsan_handle_type_mismatch(&info, pointer); } + + void __ubsan_handle_nonnull_arg(NonnullArgInfo* info, intptr_t) + { + dbgln("ubsan: null argument at %s:%d:%d", DISPLAY(info->location)); + ub_panic(); + } }