Skip to content

Commit

Permalink
FSEntry: Throw an Exception when trying to read non-existent file
Browse files Browse the repository at this point in the history
FSEntry.lookup can return null, and it would lead to a SEGV
with the attribute check, so add the forgotten check first.
  • Loading branch information
Geod24 committed Jun 11, 2024
1 parent a913071 commit 6bfde5e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6bfde5e

Please sign in to comment.