bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] linux: plug a file descriptor leak


From: Jim Meyering
Subject: [PATCH] linux: plug a file descriptor leak
Date: Fri, 27 May 2011 13:47:26 +0200

FYI,

>From 54685b5343c39e1a82fc4fc439104600d56d9e9e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 27 May 2011 13:46:40 +0200
Subject: [PATCH] linux: plug a file descriptor leak

* libparted/arch/linux.c (read_device_sysfs_file): Don't leak a
file descriptor.
---
 libparted/arch/linux.c |    4 +++-
 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);
--
1.7.5.2.660.g9f46c



reply via email to

[Prev in Thread] Current Thread [Next in Thread]