From caf4fa61abc70dd4ac159444b25b457a502fab62 Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Fri, 4 May 2012 12:23:44 +0400 Subject: [PATCH] gui/plugins.cpp: fix memleak in scandir Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/37d5e13d432353c857c585fd592133c09fbf7fdd Author: [CST] Focus Date: 2012-05-04 (Fri, 04 May 2012) --- src/gui/plugins.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index 063186016..02b4d5949 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -108,6 +108,9 @@ void CPlugins::scanDir(const char *dir) int number_of_files = scandir(dir, &namelist, 0, alphasort); + if(number_of_files < 0) + return; + for (int i = 0; i < number_of_files; i++) { std::string filename; @@ -147,7 +150,9 @@ void CPlugins::scanDir(const char *dir) } } } + free(namelist[i]); } + free(namelist); } void CPlugins::loadPlugins()