Skip to content

Commit

Permalink
Fix possible null exception in DreamResource.CreateDirectory() (#1527)
Browse files Browse the repository at this point in the history
* Fix possible null exception in `DreamResource.CreateDirectory()`

* Use `GetDirectoryName()`
  • Loading branch information
wixoaGit authored Nov 3, 2023
1 parent 6570a8c commit 4bb5b23
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion OpenDreamRuntime/Resources/DreamResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ public virtual void Output(DreamValue value) {
}

private void CreateDirectory() {
Directory.CreateDirectory(Path.GetDirectoryName(_filePath));
if (_filePath == null)
return;

string? directory = Path.GetDirectoryName(_filePath);
if (directory == null)
return;

Directory.CreateDirectory(directory);
}

public override string ToString() {
Expand Down

0 comments on commit 4bb5b23

Please sign in to comment.