Module Name: src
Committed By: tpaul
Date: Thu May 16 12:42:35 UTC 2019
Modified Files:
src/lib/lua/sqlite: sqlite.c
Log Message:
Prevent Lua from crashing if clear_bindings() is called on a statement
that failed to prepare().
ok mbalmer@
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/lib/lua/sqlite/sqlite.c:1.10
--- src/lib/lua/sqlite/sqlite.c:1.9 Wed May 10 07:36:01 2017
+++ src/lib/lua/sqlite/sqlite.c Thu May 16 12:42:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sqlite.c,v 1.9 2017/05/10 07:36:01 mbalmer Exp $ */
+/* $NetBSD: sqlite.c,v 1.10 2019/05/16 12:42:35 tpaul Exp $ */
/*
* Copyright (c) 2011, 2013, 2016, 2017 Marc Balmer <[email protected]>
@@ -336,7 +336,10 @@ stmt_clear_bindings(lua_State *L)
sqlite3_stmt **stmt;
stmt = luaL_checkudata(L, 1, SQLITE_STMT_METATABLE);
- sqlite3_clear_bindings(*stmt);
+ if (*stmt) {
+ sqlite3_clear_bindings(*stmt);
+ *stmt = NULL;
+ }
return 0;
}