Coverity: Don't close fd_cwd if fd_cwd == -1.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 8 Jun 2011 21:04:25 +0000 (22:04 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Thu, 9 Jun 2011 09:53:22 +0000 (10:53 +0100)
daemon/realpath.c

index 607381b..592e12c 100644 (file)
@@ -179,7 +179,8 @@ do_case_sensitive_path (const char *path)
     }
   }
 
     }
   }
 
-  close (fd_cwd);
+  if (fd_cwd >= 0)
+    close (fd_cwd);
 
   ret[next] = '\0';
   char *retp = strdup (ret);
 
   ret[next] = '\0';
   char *retp = strdup (ret);
@@ -190,6 +191,8 @@ do_case_sensitive_path (const char *path)
   return retp;                  /* caller frees */
 
  error:
   return retp;                  /* caller frees */
 
  error:
-  close (fd_cwd);
+  if (fd_cwd >= 0)
+    close (fd_cwd);
+
   return NULL;
 }
   return NULL;
 }