From 396de6fc9c49e6865b3130489ed39c7ea47540d1 Mon Sep 17 00:00:00 2001 From: Marc Poulhiès Date: Thu, 3 Mar 2022 13:05:17 +0100 Subject: Fix GCC plugin crash when using deny/allow list The provided function declaration F may not have valid location information. Return an empty string in this case as the two callers are already using this convention to filter out functions from being instrumented when deny/allow list are used. --- instrumentation/afl-gcc-pass.so.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentation/afl-gcc-pass.so.cc b/instrumentation/afl-gcc-pass.so.cc index 734fa170..bb5483fc 100644 --- a/instrumentation/afl-gcc-pass.so.cc +++ b/instrumentation/afl-gcc-pass.so.cc @@ -714,9 +714,11 @@ struct afl_pass : gimple_opt_pass { } + /* Returns the source file name attached to the function declaration F. If + there is no source location information, returns an empty string. */ std::string getSourceName(function *F) { - return DECL_SOURCE_FILE(F->decl); + return DECL_SOURCE_FILE(F->decl) ? DECL_SOURCE_FILE(F->decl) : ""; } -- cgit 1.4.1