summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlo Bramini <carlo.bramix@libero.it>2010-10-14 12:27:54 (GMT)
committerDaniel Veillard <veillard@redhat.com>2010-10-14 12:27:54 (GMT)
commitc43ac6698818d63e28f3f9691dba8a9cdbc6d469 (patch)
tree9c7d66c5a9880e507af2795d48eac675793460de
parent2ddecc23862bab1a9a9e51e097aefc92ec305e28 (diff)
downloadlibxml2-c43ac6698818d63e28f3f9691dba8a9cdbc6d469.tar.gz
libxml2-c43ac6698818d63e28f3f9691dba8a9cdbc6d469.tar.xz
Avoid a descriptor leak in catalog loading code
File descriptors could be leaked in xmlLoadFileContent()
-rw-r--r--catalog.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/catalog.c b/catalog.c
index af84b7c..f33a0aa 100644
--- a/catalog.c
+++ b/catalog.c
@@ -997,18 +997,15 @@ xmlLoadFileContent(const char *filename)
}
#ifdef HAVE_STAT
len = read(fd, content, size);
+ close(fd);
#else
len = fread(content, 1, size, fd);
+ fclose(fd);
#endif
if (len < 0) {
xmlFree(content);
return (NULL);
}
-#ifdef HAVE_STAT
- close(fd);
-#else
- fclose(fd);
-#endif
content[len] = 0;
return(content);