From e027965176499b578b297e8bead32a0400d07a6d Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Mon, 7 Mar 2022 19:04:29 +0100 Subject: [PATCH] fix null pointer access in unused.d --- src/dscanner/analysis/unused.d | 3 ++- src/dscanner/analysis/unused_variable.d | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dscanner/analysis/unused.d b/src/dscanner/analysis/unused.d index 890a764..9934a37 100644 --- a/src/dscanner/analysis/unused.d +++ b/src/dscanner/analysis/unused.d @@ -434,7 +434,8 @@ abstract class UnusedStorageCheck : UnusedIdentifierCheck // enum name = "abc"; // __traits(hasMember, S, name); ignoreDeclarations++; - traitsExp.templateArgumentList.accept(this); + if (traitsExp.templateArgumentList) + traitsExp.templateArgumentList.accept(this); ignoreDeclarations--; } diff --git a/src/dscanner/analysis/unused_variable.d b/src/dscanner/analysis/unused_variable.d index e5e67ee..c3b3689 100644 --- a/src/dscanner/analysis/unused_variable.d +++ b/src/dscanner/analysis/unused_variable.d @@ -117,6 +117,12 @@ final class UnusedVariableCheck : UnusedStorageCheck __traits(compiles, { int i = 2; }); } + // segfault with null templateArgumentList + void nullTest() + { + __traits(isPOD); + } + }c, sac); stderr.writeln("Unittest for UnusedVariableCheck passed."); }