[vlc-devel] [PATCH] modules/bank: prevent null-pointer dereference in AllocatePluginFile

Filip Roséen filip at atch.se
Fri Oct 28 08:54:23 CEST 2016


Given that module_InitDynamic can fail and return a NULL pointer to
signal the error, we cannot unconditionally set data-members of the
referred to vlc_plugin_t.

These changes fixes the issue by introducing an explicit branch
related to initialization.
---
 src/modules/bank.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/modules/bank.c b/src/modules/bank.c
index c202eb2..552fade 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -188,10 +188,15 @@ static int AllocatePluginFile (module_bank_t *bank, const char *abspath,
     if (plugin == NULL)
     {
         plugin = module_InitDynamic(bank->obj, abspath, true);
-        plugin->path = xstrdup(relpath);
-        plugin->mtime = st->st_mtime;
-        plugin->size = st->st_size;
+
+        if( plugin )
+        {
+            plugin->path = xstrdup(relpath);
+            plugin->mtime = st->st_mtime;
+            plugin->size = st->st_size;
+        }
     }
+
     if (plugin == NULL)
         return -1;
 
-- 
2.10.1



More information about the vlc-devel mailing list