summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
diff options
context:
space:
mode:
authorcremno <[email protected]>2014-11-26 00:54:55 +0100
committercremno <[email protected]>2014-12-02 00:00:55 +0100
commitf31733045feee3c381ee350be64e1a83682d5543 (patch)
treef31d868b8dba8783112cbce425cf8fc4a62b2c5c /mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c
parentce5a3dbcbaae84d87c4f09d4e28523a59886c7ad (diff)
downloadmruby-f31733045feee3c381ee350be64e1a83682d5543.tar.gz
mruby-f31733045feee3c381ee350be64e1a83682d5543.zip
use mrb_debug_strdup() and mrb_debug_strndup()
As they are safer to use than mrb_malloc()+strlen()+strncpy() (see #2652).
Diffstat (limited to 'mrbgems/mruby-bin-debugger/tools/mrdb/cmdmisc.c')
-rwxr-xr-xmrbgems/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 74e10ab5a..7b0806eff 100755
--- 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 {
@@ -226,10 +227,7 @@ parse_filename(mrb_state *mrb, char **sp, listcmd_parser_state *st)
len = strlen(*sp);
}
- if (len > 0) {
- st->filename = 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;
}