summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-07-06 17:02:31 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-07-06 17:02:31 +0900
commit17748ecd1ae31f755e131c841be5cb06064e7a7a (patch)
tree5b1f2323812995d217e5c85e5f37fb88a50bd368 /mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
parent7fa0a704e010b4a9d1ac96da9f8a0ffc4cb13c2e (diff)
parent7c362ee7237ec31e4e4b1bf3cc81f59e86c83573 (diff)
downloadmruby-17748ecd1ae31f755e131c841be5cb06064e7a7a.tar.gz
mruby-17748ecd1ae31f755e131c841be5cb06064e7a7a.zip
Merge branch '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.c6
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;
}