From 202a8f8a0f15ff7831307c65d518f831bd32ecb2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 10 Aug 2009 16:33:15 +0200 Subject: [PATCH] Fixed FILE leak in the dump back-end Closes https://bugzilla.novell.com/show_bug.cgi?id=529469 --- lib/dump.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/dump.c b/lib/dump.c index 0196f69..bdd1df6 100644 --- a/lib/dump.c +++ b/lib/dump.c @@ -70,7 +70,10 @@ dump_init(struct pci_access *a) { char *z = strchr(buf, '\n'); if (!z) - a->error("dump: line too long or unterminated"); + { + fclose(f); + a->error("dump: line too long or unterminated"); + } *z-- = 0; if (z >= buf && *z == '\r') *z-- = 0; @@ -95,7 +98,10 @@ dump_init(struct pci_access *a) sscanf(z, "%x", &j) == 1 && j < 256) { if (i >= 4096) - a->error("dump: At most 4096 bytes of config space are supported"); + { + fclose(f); + a->error("dump: At most 4096 bytes of config space are supported"); + } if (i >= dd->allocated) /* Need to re-allocate the buffer */ { dump_alloc_data(dev, 4096); @@ -111,9 +117,13 @@ dump_init(struct pci_access *a) z++; } if (*z) - a->error("dump: Malformed line"); + { + fclose(f); + a->error("dump: Malformed line"); + } } } + fclose(f); } static void -- 2.39.2