[libpeas] Fix finding the extension type for Lua plugin



commit 897c4ada6df032c6ee7d4ff8e653c4fe85bbb660
Author: Garrett Regier <garrett regier riftio com>
Date:   Tue Dec 30 08:41:17 2014 -0800

    Fix finding the extension type for Lua plugin
    
    If the module's table had multiple extensions we would
    leak the key and value on the stack.

 loaders/lua5.1/peas-plugin-loader-lua.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/loaders/lua5.1/peas-plugin-loader-lua.c b/loaders/lua5.1/peas-plugin-loader-lua.c
index 25582b9..eaf7cbb 100644
--- a/loaders/lua5.1/peas-plugin-loader-lua.c
+++ b/loaders/lua5.1/peas-plugin-loader-lua.c
@@ -201,16 +201,24 @@ _lua_find_extension_type (lua_State      *L,
 
   /* Must always have a valid key */
   lua_pushnil (L);
-  while (lua_next (L, -2) != 0 && found_type == G_TYPE_INVALID)
+  while (lua_next (L, -2) != 0)
     {
       if (lua_istable (L, -1))
         {
           found_type = _lua_get_gtype (L, -1);
 
-          if (found_type != G_TYPE_INVALID &&
-              !g_type_is_a (found_type, exten_type))
+          if (found_type != G_TYPE_INVALID)
             {
-              found_type = G_TYPE_INVALID;
+              if (!g_type_is_a (found_type, exten_type))
+                {
+                  found_type = G_TYPE_INVALID;
+                }
+              else
+                {
+                  /* Pop value and key */
+                  lua_pop (L, 2);
+                  break;
+                }
             }
         }
 


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