do not use strdup(3) that use malloc(3) inside; should use mrb_malloc()

This commit is contained in:
Yukihiro Matsumoto
2012-04-26 08:43:05 +09:00
parent c6f5f637e2
commit 0486c48b1a
+5 -1
View File
@@ -83,7 +83,11 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
}
else if (cmdline) {
if (!args->cmdline) {
args->cmdline = strdup(argv[0]);
char *buf;
buf = mrb_malloc(mrb, strlen(argv[0])+1);
strcpy(buf, argv[0]);
args->cmdline = buf;
}
else {
args->cmdline = mrb_realloc(mrb, args->cmdline, strlen(args->cmdline)+strlen(argv[0])+2);