summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'process.c')
-rw-r--r--process.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/process.c b/process.c
index 51683de2fa..cfc2e8d5f0 100644
--- a/process.c
+++ b/process.c
@@ -2477,8 +2477,10 @@ rb_fork(int *status, int (*chfunc)(void*, char *, size_t), void *charg, VALUE fd
#ifdef FD_CLOEXEC
err = errno;
write(ep[1], &err, sizeof(err));
- errmsg[errmsg_buflen-1] = '\0';
- write(ep[1], errmsg, strlen(errmsg));
+ if (errmsg && 0 < errmsg_buflen) {
+ errmsg[errmsg_buflen-1] = '\0';
+ write(ep[1], errmsg, strlen(errmsg));
+ }
#endif
#if EXIT_SUCCESS == 127
_exit(EXIT_FAILURE);