X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fprocess%2Fposix_spawn_file_actions_addopen.c;h=82bbcec9eb42cd5f112d2a6b66d0769b8349f11f;hb=122002f0ddf267977282f05066a0794e31661501;hp=5e2c86d9b12e93da3472be052cce0b1b6bd57a9c;hpb=a0ae0b09368e6dbfa82860187dcd6fdf86d86fee;p=musl diff --git a/src/process/posix_spawn_file_actions_addopen.c b/src/process/posix_spawn_file_actions_addopen.c index 5e2c86d9..82bbcec9 100644 --- a/src/process/posix_spawn_file_actions_addopen.c +++ b/src/process/posix_spawn_file_actions_addopen.c @@ -4,8 +4,9 @@ #include #include "fdop.h" -int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, const char *path, int flags, mode_t mode) +int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode) { + if (fd < 0) return EBADF; struct fdop *op = malloc(sizeof *op + strlen(path) + 1); if (!op) return ENOMEM; op->cmd = FDOP_OPEN; @@ -13,7 +14,8 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, con op->oflag = flags; op->mode = mode; strcpy(op->path, path); - op->next = fa->__actions; + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; fa->__actions = op; return 0; }