]> ruderich.org/simon Gitweb - coloredstderr/coloredstderr.git/commitdiff
fcntl(): Don't call dup_fd() if real_fcntl() failed.
authorSimon Ruderich <simon@ruderich.org>
Fri, 31 May 2013 16:37:55 +0000 (18:37 +0200)
committerSimon Ruderich <simon@ruderich.org>
Fri, 31 May 2013 16:37:55 +0000 (18:37 +0200)
src/coloredstderr.c

index dbcfd235cf649a7a412b6f1ca6f896c1bbf71c71..b2ef2975ef8d6e5ffae8625e925ae5caf46e3523 100644 (file)
@@ -280,7 +280,7 @@ int fcntl(int fd, int cmd, int arg) {
 
     result = real_fcntl(fd, cmd, arg);
     /* We only care about duping fds. */
-    if (cmd == F_DUPFD) {
+    if (cmd == F_DUPFD && result != -1) {
         int saved_errno = errno;
         dup_fd(fd, result);
         errno = saved_errno;