From 6bfde5eea53ac9ccc266ae576c5371441ffecf73 Mon Sep 17 00:00:00 2001 From: Mathias Lang Date: Tue, 11 Jun 2024 11:31:58 +0200 Subject: [PATCH] FSEntry: Throw an Exception when trying to read non-existent file FSEntry.lookup can return null, and it would lead to a SEGV with the attribute check, so add the forgotten check first. --- source/dub/test/base.d | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dub/test/base.d b/source/dub/test/base.d index a17587f0d..475dd7ead 100644 --- a/source/dub/test/base.d +++ b/source/dub/test/base.d @@ -736,6 +736,7 @@ public class FSEntry public ubyte[] readFile (NativePath path) const scope { auto entry = this.lookup(path); + enforce(entry !is null, "No such file: " ~ path.toNativeString()); enforce(entry.attributes.type == Type.File, "Trying to read a directory"); // This is a hack to make poisoning a file possible. // However, it is rather crude and doesn't allow to poison directory.