Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/lua/sqlite Prevent Lua from crashing if clear_bindings()...



details:   https://anonhg.NetBSD.org/src/rev/6e0cd5d557b6
branches:  trunk
changeset: 451337:6e0cd5d557b6
user:      tpaul <tpaul%NetBSD.org@localhost>
date:      Thu May 16 12:42:35 2019 +0000

description:
Prevent Lua from crashing if clear_bindings() is called on a statement
that failed to prepare().

ok mbalmer@

diffstat:

 lib/lua/sqlite/sqlite.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r 4d248afe7820 -r 6e0cd5d557b6 lib/lua/sqlite/sqlite.c
--- a/lib/lua/sqlite/sqlite.c   Thu May 16 10:28:19 2019 +0000
+++ b/lib/lua/sqlite/sqlite.c   Thu May 16 12:42:35 2019 +0000
@@ -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 <marc%msys.ch@localhost>
@@ -336,7 +336,10 @@
        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;
 }
 



Home | Main Index | Thread Index | Old Index