]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage_backend.c: avoid closing a negative file descriptor
authorJim Meyering <meyering@redhat.com>
Tue, 2 Feb 2010 10:11:49 +0000 (11:11 +0100)
committerJim Meyering <meyering@redhat.com>
Tue, 2 Feb 2010 11:07:19 +0000 (12:07 +0100)
* src/storage/storage_backend.c (virStorageBackendRunProgRegex):
Don't close a negative (read-only) file descriptor.

src/storage/storage_backend.c

index bc656f24e0b86062d7508672b8ce97dca741947b..e79294a840f96633767ef265f0dbef0f098f7f31 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * storage_backend.c: internal storage driver backend contract
  *
- * Copyright (C) 2007-2009 Red Hat, Inc.
+ * Copyright (C) 2007-2010 Red Hat, Inc.
  * Copyright (C) 2007-2008 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -1326,8 +1326,10 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
 
     if (list)
         fclose(list);
-    else
-        close(fd);
+    else {
+        if (fd >= 0)
+            close(fd);
+    }
 
     while ((err = waitpid(child, &exitstatus, 0) == -1) && errno == EINTR);