Module: sems
Branch: master
Commit: f6964e90a98b7b5324b789930d2341be37055e5a
URL: 
https://github.com/sems-server/sems/commit/f6964e90a98b7b5324b789930d2341be37055e5a

Author: Juha Heinanen <[email protected]>
Committer: Juha Heinanen <[email protected]>
Date: 2015-02-21T11:49:07+02:00

core: close file descriptor after use
- patch provided by Joe Stusick

---

Modified: core/AmCachedAudioFile.cpp

---

Diff:  
https://github.com/sems-server/sems/commit/f6964e90a98b7b5324b789930d2341be37055e5a.diff
Patch: 
https://github.com/sems-server/sems/commit/f6964e90a98b7b5324b789930d2341be37055e5a.patch

---

diff --git a/core/AmCachedAudioFile.cpp b/core/AmCachedAudioFile.cpp
index e56ec41..f43ecd4 100644
--- a/core/AmCachedAudioFile.cpp
+++ b/core/AmCachedAudioFile.cpp
@@ -65,6 +65,7 @@ int AmFileCache::load(const std::string& filename) {
   if (fstat(fd,  &sbuf) == -1) {
     ERROR("cannot stat file '%s'.\n", 
          name.c_str());
+    close(fd);
     return -2;
   }
        
@@ -72,10 +73,12 @@ int AmFileCache::load(const std::string& filename) {
                   fd, 0)) == (caddr_t)(-1)) {
     ERROR("cannot mmap file '%s'.\n", 
          name.c_str());
+    close(fd);
     return -3;
   }
 
   data_size = sbuf.st_size;
+  close(fd);
 
   return 0;
 }

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to