[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdesupport/3.5/kdesupport/akode/lib
From:       Hasso Tepper <hasso () kde ! org>
Date:       2007-10-17 13:21:41
Message-ID: 1192627301.339597.11807.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 726300 by hasso:

Backport 726298.
Don't leak file descriptors if fstat(2) fails for some reason.


 M  +8 -2      localfile.cpp  
 M  +4 -1      mmapfile.cpp  


--- branches/kdesupport/3.5/kdesupport/akode/lib/localfile.cpp #726299:726300
@@ -58,7 +58,10 @@
 
     struct stat stat;
     _fd = ::open(filename, O_RDONLY);
-    if (fstat(_fd, &stat) < 0) return false;
+    if (fstat(_fd, &stat) < 0) {
+        ::close(_fd);
+        return false;
+    }
     len = stat.st_size;
 
     m_readable = true;
@@ -74,7 +77,10 @@
 
     struct stat stat;
     _fd = ::open(filename, O_RDWR);
-    if (fstat(_fd, &stat) < 0) return false;
+    if (fstat(_fd, &stat) < 0) {
+        ::close(_fd);
+        return false;
+    }
     len = stat.st_size;
 
     m_readable = true;
--- branches/kdesupport/3.5/kdesupport/akode/lib/mmapfile.cpp #726299:726300
@@ -58,7 +58,10 @@
     struct stat stat;
 
     fd = ::open(filename, O_RDONLY);
-    if (fstat(fd, &stat) < 0) return false;
+    if (fstat(fd, &stat) < 0) {
+        ::close(fd);
+        return false;
+    }
     len = stat.st_size;
     pos = 0;
 
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic