xmlIO: Fix an FD leak on gzdopen() failure

According to the documentation, gzdopen() does not close the FD on
failure (but does effectively close it on success, since gzclose()
closes it).

Coverity issues: #60440, #60441

https://bugzilla.gnome.org/show_bug.cgi?id=731990
diff --git a/xmlIO.c b/xmlIO.c
index d1544f3..5baeba3 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -1159,7 +1159,12 @@
     gzFile fd;
 
     if (!strcmp(filename, "-")) {
-        fd = gzdopen(dup(fileno(stdin)), "rb");
+        int duped_fd = dup(fileno(stdin));
+        fd = gzdopen(duped_fd, "rb");
+        if (fd == Z_NULL) {
+            close(duped_fd);  /* gzdOpen() does not close on failure */
+        }
+
 	return((void *) fd);
     }
 
@@ -1233,7 +1238,12 @@
 
     snprintf(mode, sizeof(mode), "wb%d", compression);
     if (!strcmp(filename, "-")) {
-        fd = gzdopen(dup(fileno(stdout)), mode);
+        int duped_fd = dup(fileno(stdout));
+        fd = gzdopen(duped_fd, "rb");
+        if (fd == Z_NULL) {
+            close(duped_fd);  /* gzdOpen() does not close on failure */
+        }
+
 	return((void *) fd);
     }