diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-14 13:01:47 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-14 13:01:47 +0900 |
| commit | ad194bd46bd51aa5bfd5863f3ce18dee8a347c29 (patch) | |
| tree | 80abce2c9afc914a6d62d7f5a957eac4c536247b | |
| parent | 73798bff6587cb39b1d59019876fc8a571b6c31c (diff) | |
| download | mruby-ad194bd46bd51aa5bfd5863f3ce18dee8a347c29.tar.gz mruby-ad194bd46bd51aa5bfd5863f3ce18dee8a347c29.zip | |
error.c: the error message may contain `NUL` character.
| -rw-r--r-- | src/backtrace.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backtrace.c b/src/backtrace.c index 65cb0da1c..d6648cc43 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -102,24 +102,24 @@ print_backtrace(mrb_state *mrb, struct RObject *exc, mrb_value backtrace) mrb_int i; mrb_int n = RARRAY_LEN(backtrace); mrb_value *loc, mesg; - FILE *stream = stderr; if (n != 0) { if (n > 1) { - fprintf(stream, "trace (most recent call last):\n"); + fprintf(stderr, "trace (most recent call last):\n"); } for (i=n-1,loc=&RARRAY_PTR(backtrace)[i]; i>0; i--,loc--) { if (mrb_string_p(*loc)) { - fprintf(stream, "\t[%d] %.*s\n", + fprintf(stderr, "\t[%d] %.*s\n", (int)i, (int)RSTRING_LEN(*loc), RSTRING_PTR(*loc)); } } if (mrb_string_p(*loc)) { - fprintf(stream, "%.*s: ", (int)RSTRING_LEN(*loc), RSTRING_PTR(*loc)); + fprintf(stderr, "%.*s: ", (int)RSTRING_LEN(*loc), RSTRING_PTR(*loc)); } } mesg = mrb_exc_inspect(mrb, mrb_obj_value(exc)); - fprintf(stream, "%.*s\n", (int)RSTRING_LEN(mesg), RSTRING_PTR(mesg)); + fwrite(RSTRING_PTR(mesg), RSTRING_LEN(mesg), 1, stderr); + fputc('\n', stderr); } /* mrb_print_backtrace |
