Permalink
Browse files

Use `snprintf()` to stringify fixnum numbers; fix #3492

  • Loading branch information...
matz committed Mar 19, 2017
1 parent cea6a16 commit dcf6a413cab097e39d2d883d7c8c297d29ea43b8
Showing with 6 additions and 9 deletions.
  1. +6 −9 src/backtrace.c
View
@@ -74,14 +74,13 @@ static void
get_backtrace_i(mrb_state *mrb, struct backtrace_location *loc, void *data)
{
mrb_value ary, str;
int ai;
char buf[32];
int ai = mrb_gc_arena_save(mrb);
ai = mrb_gc_arena_save(mrb);
ary = mrb_obj_value((struct RArray*)data);
str = mrb_str_new_cstr(mrb, loc->filename);
mrb_str_cat_lit(mrb, str, ":");
mrb_str_concat(mrb, str, mrb_fixnum_to_str(mrb, mrb_fixnum_value(loc->lineno), 10));
snprintf(buf, sizeof(buf), ":%d", loc->lineno);
if (loc->method) {
mrb_str_cat_lit(mrb, str, ":in ");
@@ -399,16 +398,14 @@ mrb_restore_backtrace(mrb_state *mrb)
int ai;
mrb_backtrace_entry *entry;
mrb_value mrb_entry;
char buf[32];
ai = mrb_gc_arena_save(mrb);
entry = &(mrb->backtrace.entries[i]);
mrb_entry = mrb_str_new_cstr(mrb, entry->filename);
mrb_str_cat_lit(mrb, mrb_entry, ":");
mrb_str_concat(mrb, mrb_entry,
mrb_fixnum_to_str(mrb,
mrb_fixnum_value(entry->lineno),
10));
snprintf(buf, sizeof(buf), ":%d", entry->lineno);
mrb_str_cat_cstr(mrb, mrb_entry, buf);
if (entry->method_id != 0) {
mrb_str_cat_lit(mrb, mrb_entry, ":in ");

0 comments on commit dcf6a41

Please sign in to comment.