]> granicus.if.org Git - apache/commitdiff
The pool and db object to be used should be created before trying to acquire a driver...
authorDaniel Gruno <humbedooh@apache.org>
Mon, 14 Jan 2013 12:04:38 +0000 (12:04 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Mon, 14 Jan 2013 12:04:38 +0000 (12:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1432892 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/lua_dbd.c

index 7c334d68a2d231c17fefe95a07e2dc6097cb736a..4c71a1783471e606720ff5310b6e3098d1bc5241 100644 (file)
@@ -757,15 +757,16 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
             }
             apr_pool_tag(pool, "lua_dbd_pool");
             apr_dbd_init(pool);
-            
-            rc = apr_dbd_get_driver(r->server->process->pool, type, &db->driver);
+            dbdhandle = apr_pcalloc(pool, sizeof(ap_dbd_t));
+            rc = apr_dbd_get_driver(pool, type, &dbdhandle->driver);
             if (rc == APR_SUCCESS) {
                 luaL_checktype(L, 3, LUA_TSTRING);
                 arguments = lua_tostring(L, 3);
                 lua_settop(L, 0);
+                
                 if (strlen(arguments)) {
-                    rc = apr_dbd_open_ex(db->driver, r->server->process->pool, 
-                            arguments, &db->handle, &error);
+                    rc = apr_dbd_open_ex(dbdhandle->driver, pool, 
+                            arguments, &dbdhandle->handle, &error);
                     if (rc == APR_SUCCESS) {
                         db = lua_push_db_handle(L, r, LUA_DBTYPE_APR_DBD, pool);
                         db->driver = dbdhandle->driver;
@@ -787,6 +788,7 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
                 lua_pushnil(L);
                 lua_pushliteral(L,
                                 "No database connection string was specified.");
+                apr_pool_destroy(pool);
                 return (2);
             }
             else {
@@ -809,6 +811,7 @@ AP_LUA_DECLARE(int) lua_db_acquire(lua_State *L)
                                 "mod_lua not compatible with APR in get_driver");
                 }
                 lua_pushinteger(L, rc);
+                apr_pool_destroy(pool);
                 return 3;
             }
         }