summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-14 03:30:03 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-14 03:30:03 +0000
commit4f3c4c7d6d2ab8bf81b5e2a26ba844a6727589fc (patch)
tree8f7d5223a8e8c2c7ef213d5c8fddd2b69e23a9bc /process.c
parent8b88f70a842009d88feb6d46c4015ba9f15585c0 (diff)
RSTRING_PTR is not guaranteed to be char*-aligned
This commit eliminates (char **)RSTRING_PTR(...) like usages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/process.c b/process.c
index c1c8432a45..ca172d3e56 100644
--- a/process.c
+++ b/process.c
@@ -1283,7 +1283,7 @@ proc_exec_cmd(const char *prog, VALUE argv_str, VALUE envp_str)
rb_w32_uaspawn(P_OVERLAY, prog, argv);
return errno;
#else
- envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL;
+ envp = envp_str ? RB_IMEMO_TMPBUF_PTR(envp_str) : NULL;
if (envp_str)
execve(prog, argv, envp); /* async-signal-safe */
else
@@ -1324,7 +1324,7 @@ proc_exec_sh(const char *str, VALUE envp_str)
}
#else
if (envp_str)
- execle("/bin/sh", "sh", "-c", str, (char *)NULL, (char **)RSTRING_PTR(envp_str)); /* async-signal-safe */
+ execle("/bin/sh", "sh", "-c", str, (char *)NULL, RB_IMEMO_TMPBUF_PTR(envp_str)); /* async-signal-safe */
else
execl("/bin/sh", "sh", "-c", str, (char *)NULL); /* async-signal-safe (since SUSv4) */
#endif /* _WIN32 */
@@ -2264,7 +2264,8 @@ rb_exec_fillarg(VALUE prog, int argc, VALUE *argv, VALUE env, VALUE opthash, VAL
p += strlen(p) + 1;
}
rb_str_buf_cat(argv_str, (char *)&null, sizeof(null)); /* terminator for execve. */
- eargp->invoke.cmd.argv_str = argv_str;
+ eargp->invoke.cmd.argv_str =
+ rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(argv_str);
}
RB_GC_GUARD(execarg_obj);
}
@@ -2464,7 +2465,8 @@ rb_execarg_parent_start1(VALUE execarg_obj)
}
p = NULL;
rb_str_buf_cat(envp_str, (char *)&p, sizeof(p));
- eargp->envp_str = envp_str;
+ eargp->envp_str =
+ rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString(envp_str);
eargp->envp_buf = envp_buf;
/*