Module Name: src Committed By: snj Date: Sat Jun 3 17:11:51 UTC 2017
Modified Files: src/lib/lua/sqlite [netbsd-7]: sqlite.c Log Message: Pull up following revision(s) (requested by mbalmer in ticket #1416): lib/lua/sqlite/sqlite.c: revision 1.9 Guard against double freeing of objects (explicit by the Lua program, then later by the garbage collector). This fixes PR bin/52218. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.7.2.1 src/lib/lua/sqlite/sqlite.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/lua/sqlite/sqlite.c diff -u src/lib/lua/sqlite/sqlite.c:1.7 src/lib/lua/sqlite/sqlite.c:1.7.2.1 --- src/lib/lua/sqlite/sqlite.c:1.7 Sat Jul 19 18:38:34 2014 +++ src/lib/lua/sqlite/sqlite.c Sat Jun 3 17:11:51 2017 @@ -1,7 +1,7 @@ -/* $NetBSD: sqlite.c,v 1.7 2014/07/19 18:38:34 lneto Exp $ */ +/* $NetBSD: sqlite.c,v 1.7.2.1 2017/06/03 17:11:51 snj Exp $ */ /* - * Copyright (c) 2011, 2013 Marc Balmer <m...@msys.ch> + * Copyright (c) 2011, 2013, 2016, 2017 Marc Balmer <m...@msys.ch> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -120,7 +120,11 @@ db_close(lua_State *L) sqlite3 **db; db = luaL_checkudata(L, 1, SQLITE_DB_METATABLE); - lua_pushinteger(L, sqlite3_close(*db)); + if (*db) { + lua_pushinteger(L, sqlite3_close(*db)); + *db = NULL; + } else + lua_pushnil(L); return 1; } @@ -342,7 +346,10 @@ stmt_finalize(lua_State *L) sqlite3_stmt **stmt; stmt = luaL_checkudata(L, 1, SQLITE_STMT_METATABLE); - sqlite3_finalize(*stmt); + if (*stmt) { + sqlite3_finalize(*stmt); + *stmt = NULL; + } return 0; }