From: Richard W.M. Jones Date: Wed, 8 Jun 2011 21:04:25 +0000 (+0100) Subject: Coverity: Don't close fd_cwd if fd_cwd == -1. X-Git-Tag: 1.8.8~10 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=6cdd349e6964636c2b7ae71453dca33716dda486;p=libguestfs.git Coverity: Don't close fd_cwd if fd_cwd == -1. (cherry picked from commit 76dfb74324fa0daa343d7edf89bd05e1fe7b4db0) --- diff --git a/daemon/realpath.c b/daemon/realpath.c index 89f7737..ff258be 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -183,7 +183,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); @@ -194,6 +195,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; }