rb_source_location() may return nil.

* vm.c (rb_source_location): return nil if path is not found.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-11-16 05:35:58 +00:00
parent b3cab0dc74
commit 7a666c6766
2 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ error_pos_str(void)
int sourceline; int sourceline;
VALUE sourcefile = rb_source_location(&sourceline); VALUE sourcefile = rb_source_location(&sourceline);
if (sourcefile) { if (!NIL_P(sourcefile)) {
ID caller_name; ID caller_name;
if (sourceline == 0) { if (sourceline == 0) {
return rb_sprintf("%"PRIsVALUE": ", sourcefile); return rb_sprintf("%"PRIsVALUE": ", sourcefile);

4
vm.c
View File

@ -1293,7 +1293,7 @@ rb_source_location(int *pline)
} }
else { else {
if (pline) *pline = 0; if (pline) *pline = 0;
return 0; return Qnil;
} }
} }
@ -1301,7 +1301,7 @@ const char *
rb_source_loc(int *pline) rb_source_loc(int *pline)
{ {
VALUE path = rb_source_location(pline); VALUE path = rb_source_location(pline);
if (!path) return 0; if (!NIL_P(path)) return NULL;
return RSTRING_PTR(path); return RSTRING_PTR(path);
} }