From 35f0c59c05b15e3f946653a1b78d996208cc6ae2 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 25 Oct 2013 19:42:19 +0000 Subject: close(fd), then set errno --- lib/libc/gen/shm_open.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/shm_open.c b/lib/libc/gen/shm_open.c index 02cac2f2dac..ccbe82a6c70 100644 --- a/lib/libc/gen/shm_open.c +++ b/lib/libc/gen/shm_open.c @@ -1,4 +1,4 @@ -/* $OpenBSD: shm_open.c,v 1.2 2013/06/02 21:08:19 tedu Exp $ */ +/* $OpenBSD: shm_open.c,v 1.3 2013/10/25 19:42:18 tedu Exp $ */ /* * Copyright (c) 2013 Ted Unangst * @@ -61,13 +61,13 @@ shm_open(const char *path, int flags, mode_t mode) if (fd == -1) return -1; if (fstat(fd, &sb) == -1 || !S_ISREG(sb.st_mode)) { - errno = EINVAL; close(fd); + errno = EINVAL; return -1; } if (sb.st_uid != getuid()) { - errno = EPERM; close(fd); + errno = EPERM; return -1; } return fd; -- cgit v1.2.3