From 52b2a16e1abd059f75f04b6c806eefa604297e97 Mon Sep 17 00:00:00 2001 From: Vladiwostok <55026261+Vladiwostok@users.noreply.github.com> Date: Wed, 1 Nov 2023 11:45:10 +0200 Subject: [PATCH] Add null terminator to string pointers (#77) --- .gitignore | 3 +++ src/dscanner/analysis/helpers.d | 6 +++--- src/dscanner/analysis/run.d | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 4d65886..6e1d6c5 100755 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # Sublime Text 2 *.sublime-workspace +# Idea stuff +.idea/ + # Subversion .svn/ diff --git a/src/dscanner/analysis/helpers.d b/src/dscanner/analysis/helpers.d index 7111fae..9cf9dce 100644 --- a/src/dscanner/analysis/helpers.d +++ b/src/dscanner/analysis/helpers.d @@ -502,14 +502,14 @@ void assertAnalyzerWarningsDMD(string code, const StaticAnalysisConfig config, b global.params.useUnitTests = true; global.path = new Strings(); - global.path.push((dmdParentDir ~ "/dmd").ptr); - global.path.push((dmdParentDir ~ "/dmd/druntime/src").ptr); + global.path.push((dmdParentDir ~ "/dmd" ~ "\0").ptr); + global.path.push((dmdParentDir ~ "/dmd/druntime/src" ~ "\0").ptr); initDMD(); auto input = cast(char[]) code; input ~= '\0'; - auto t = dmd.frontend.parseModule(cast(const(char)[]) file, cast(const (char)[]) input); + auto t = dmd.frontend.parseModule(cast(const(char)[]) file, cast(const (char)[]) input); if (semantic) t.module_.fullSemantic(); diff --git a/src/dscanner/analysis/run.d b/src/dscanner/analysis/run.d index 97a5598..653e1bc 100644 --- a/src/dscanner/analysis/run.d +++ b/src/dscanner/analysis/run.d @@ -405,8 +405,8 @@ bool analyze(string[] fileNames, const StaticAnalysisConfig config, string error global.params.useUnitTests = true; global.path = new Strings(); - global.path.push((dmdParentDir ~ "/dmd").ptr); - global.path.push((dmdParentDir ~ "/dmd/druntime/src").ptr); + global.path.push((dmdParentDir ~ "/dmd" ~ "\0").ptr); + global.path.push((dmdParentDir ~ "/dmd/druntime/src" ~ "\0").ptr); initDMD(); @@ -1245,7 +1245,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN if (moduleName.shouldRunDmd!(FinalAttributeChecker!ASTCodegen)(config)) visitors ~= new FinalAttributeChecker!ASTCodegen(fileName); - + if (moduleName.shouldRunDmd!(ImportSortednessCheck!ASTCodegen)(config)) visitors ~= new ImportSortednessCheck!ASTCodegen(fileName); @@ -1254,10 +1254,10 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN if (moduleName.shouldRunDmd!(RedundantAttributesCheck!ASTCodegen)(config)) visitors ~= new RedundantAttributesCheck!ASTCodegen(fileName); - + if (moduleName.shouldRunDmd!(LengthSubtractionCheck!ASTCodegen)(config)) visitors ~= new LengthSubtractionCheck!ASTCodegen(fileName); - + if (moduleName.shouldRunDmd!(AliasSyntaxCheck!ASTCodegen)(config)) visitors ~= new AliasSyntaxCheck!ASTCodegen(fileName); @@ -1266,7 +1266,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN if (moduleName.shouldRunDmd!(ConstructorCheck!ASTCodegen)(config)) visitors ~= new ConstructorCheck!ASTCodegen(fileName); - + if (moduleName.shouldRunDmd!(AssertWithoutMessageCheck!ASTCodegen)(config)) visitors ~= new AssertWithoutMessageCheck!ASTCodegen( fileName, @@ -1287,22 +1287,22 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN fileName, config.trust_too_much == Check.skipTests && !ut ); - + if (moduleName.shouldRunDmd!(AutoRefAssignmentCheck!ASTCodegen)(config)) visitors ~= new AutoRefAssignmentCheck!ASTCodegen(fileName); - + if (moduleName.shouldRunDmd!(LogicPrecedenceCheck!ASTCodegen)(config)) visitors ~= new LogicPrecedenceCheck!ASTCodegen( fileName, config.logical_precedence_check == Check.skipTests && !ut ); - + if (moduleName.shouldRunDmd!(UnusedLabelCheck!ASTCodegen)(config)) visitors ~= new UnusedLabelCheck!ASTCodegen( fileName, config.unused_label_check == Check.skipTests && !ut ); - + if (moduleName.shouldRunDmd!(BuiltinPropertyNameCheck!ASTCodegen)(config)) visitors ~= new BuiltinPropertyNameCheck!ASTCodegen(fileName); @@ -1335,7 +1335,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN fileName, config.static_if_else_check == Check.skipTests && !ut ); - + if (moduleName.shouldRunDmd!(UselessAssertCheck!ASTCodegen)(config)) visitors ~= new UselessAssertCheck!ASTCodegen( fileName, @@ -1345,7 +1345,7 @@ MessageSet analyzeDmd(string fileName, ASTCodegen.Module m, const char[] moduleN foreach (visitor; visitors) { m.accept(visitor); - + foreach (message; visitor.messages) set.insert(message); }