[Libguestfs] [PATCH 04/13] Coverity: Don't close fd_cwd if fd_cwd == -1.

Richard W.M. Jones rjones at redhat.com
Thu Jun 9 10:17:03 UTC 2011


---
 daemon/realpath.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/daemon/realpath.c b/daemon/realpath.c
index 607381b..592e12c 100644
--- a/daemon/realpath.c
+++ b/daemon/realpath.c
@@ -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);
@@ -190,6 +191,8 @@ do_case_sensitive_path (const char *path)
   return retp;                  /* caller frees */
 
  error:
-  close (fd_cwd);
+  if (fd_cwd >= 0)
+    close (fd_cwd);
+
   return NULL;
 }
-- 
1.7.5.1




More information about the Libguestfs mailing list