summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-05-27 13:46:40 +0200
committerJim Meyering <meyering@redhat.com>2011-05-27 13:47:24 +0200
commit57eee615897283e0c4560a0849a568b23108926e (patch)
tree1239cf0a5089feaebca50da21f89ba9da2f6b5e1
parent0bb7d21ba6289f5aa9114ae3b4cd844c7debc07f (diff)
downloadparted-57eee615897283e0c4560a0849a568b23108926e.tar.gz
linux: plug a file descriptor leak
* libparted/arch/linux.c (read_device_sysfs_file): Don't leak a file descriptor.
-rw-r--r--libparted/arch/linux.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 05962e0..6ce6a3f 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -914,8 +914,10 @@ read_device_sysfs_file (PedDevice *dev, const char *file)
if ((f = fopen (name_buf, "r")) == NULL)
return NULL;
- if (fgets (buf, 255, f) == NULL)
+ if (fgets (buf, 255, f) == NULL) {
+ fclose (f);
return NULL;
+ }
fclose (f);
return strip_name (buf);