diff --git a/xmlIO.c b/xmlIO.c index cc861402..b5615c45 100644 --- a/xmlIO.c +++ b/xmlIO.c @@ -1060,7 +1060,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) { if (xzStream == NULL) { close(copy); } else { - if ((__libxml2_xzcompressed(xzStream) > 0) || + int compressed = (__libxml2_xzcompressed(xzStream) > 0); + + if ((compressed) || /* Try to rewind if not gzip compressed */ (pos < 0) || (lseek(fd, pos, SEEK_SET) < 0)) { @@ -1071,7 +1073,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) { buf->context = xzStream; buf->readcallback = xmlXzfileRead; buf->closecallback = xmlXzfileClose; - buf->compressed = 1; + buf->compressed = compressed; return(XML_ERR_OK); } @@ -1097,7 +1099,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) { if (gzStream == NULL) { close(copy); } else { - if ((gzdirect(gzStream) == 0) || + int compressed = (gzdirect(gzStream) == 0); + + if ((compressed) || /* Try to rewind if not gzip compressed */ (pos < 0) || (lseek(fd, pos, SEEK_SET) < 0)) { @@ -1108,7 +1112,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) { buf->context = gzStream; buf->readcallback = xmlGzfileRead; buf->closecallback = xmlGzfileClose; - buf->compressed = 1; + buf->compressed = compressed; return(XML_ERR_OK); }