Module Name: src
Committed By: snj
Date: Sun Jul 23 14:19:28 UTC 2017
Modified Files:
src/lib/lua/sqlite [netbsd-6]: sqlite.c
Log Message:
Pull up following revision(s) (requested by mbalmer in ticket #1452):
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.3 -r1.3.4.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.3 src/lib/lua/sqlite/sqlite.c:1.3.4.1
--- src/lib/lua/sqlite/sqlite.c:1.3 Sat Oct 15 12:58:20 2011
+++ src/lib/lua/sqlite/sqlite.c Sun Jul 23 14:19:27 2017
@@ -1,7 +1,7 @@
-/* $NetBSD: sqlite.c,v 1.3 2011/10/15 12:58:20 mbalmer Exp $ */
+/* $NetBSD: sqlite.c,v 1.3.4.1 2017/07/23 14:19:27 snj Exp $ */
/*
- * Copyright (c) 2011 Marc Balmer <[email protected]>
+ * Copyright (c) 2011, 2013, 2016, 2017 Marc Balmer <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -117,7 +117,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;
}
@@ -339,7 +343,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;
}