diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-06 17:01:37 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-07-06 17:01:37 +0900 |
| commit | 7c362ee7237ec31e4e4b1bf3cc81f59e86c83573 (patch) | |
| tree | 5b1f2323812995d217e5c85e5f37fb88a50bd368 /mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c | |
| parent | 7fa0a704e010b4a9d1ac96da9f8a0ffc4cb13c2e (diff) | |
| parent | f31733045feee3c381ee350be64e1a83682d5543 (diff) | |
| download | mruby-7c362ee7237ec31e4e4b1bf3cc81f59e86c83573.tar.gz mruby-7c362ee7237ec31e4e4b1bf3cc81f59e86c83573.zip | |
Merge branch 'mrb_debug_strdup-and-strndup' of https://github.com/cremno/mruby into cremno-mrb_debug_strdup-and-strndup
Diffstat (limited to 'mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c')
| -rw-r--r-- | mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c index a05ff9415..fde65fbef 100644 --- a/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c +++ b/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c @@ -8,6 +8,7 @@ #include <string.h> #include "apilist.h" +#include "apistring.h" #include <mruby/compile.h> typedef struct help_msg { @@ -232,10 +233,7 @@ parse_filename(mrb_state *mrb, char **sp, listcmd_parser_state *st) len = strlen(*sp); } - if (len > 0) { - st->filename = (char*)mrb_malloc(mrb, len + 1); - strncpy(st->filename, *sp, len); - st->filename[len] = '\0'; + if (len > 0 && (st->filename = mrb_debug_strndup(mrb, *sp, len)) != NULL) { *sp += len; return TRUE; } |
