Skip to content

Commit

Permalink
Check for null/nil user before retrieving home
Browse files Browse the repository at this point in the history
Fixes #7735
  • Loading branch information
headius committed Mar 29, 2023
1 parent 95c5be4 commit 1e8d725
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ public static IRubyObject home(ThreadContext context, IRubyObject recv) {

@JRubyMethod(name = "home", meta = true)
public static IRubyObject home(ThreadContext context, IRubyObject recv, IRubyObject user) {
if (user == null || user.isNil()) {
return getHomeDirectoryPath(context);
}

RubyString userString = user.convertToString();

userString.verifyAsciiCompatible();
Expand Down

0 comments on commit 1e8d725

Please sign in to comment.