Permalink
Browse files

Avoid a descriptor leak in catalog loading code

File descriptors could be leaked in xmlLoadFileContent()
  • Loading branch information...
1 parent 2ddecc2 commit c43ac6698818d63e28f3f9691dba8a9cdbc6d469 Carlo Bramini committed with veillard Oct 14, 2010
Showing with 2 additions and 5 deletions.
  1. +2 −5 catalog.c
View
@@ -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);

0 comments on commit c43ac66

Please sign in to comment.