Source-Changes-HG archive

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

[src/netbsd-6]: src/lib/lua/sqlite Pull up following revision(s) (requested b...



details:   https://anonhg.NetBSD.org/src/rev/cb80f880be54
branches:  netbsd-6
changeset: 777192:cb80f880be54
user:      snj <snj%NetBSD.org@localhost>
date:      Sun Jul 23 14:19:27 2017 +0000

description:
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.

diffstat:

 lib/lua/sqlite/sqlite.c |  15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r a690c2652e23 -r cb80f880be54 lib/lua/sqlite/sqlite.c
--- a/lib/lua/sqlite/sqlite.c   Fri Jul 21 04:53:34 2017 +0000
+++ b/lib/lua/sqlite/sqlite.c   Sun Jul 23 14:19:27 2017 +0000
@@ -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 <marc%msys.ch@localhost>
+ * Copyright (c) 2011, 2013, 2016, 2017 Marc Balmer <marc%msys.ch@localhost>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -117,7 +117,11 @@
        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 @@
        sqlite3_stmt **stmt;
 
        stmt = luaL_checkudata(L, 1, SQLITE_STMT_METATABLE);
-       sqlite3_finalize(*stmt);
+       if (*stmt) {
+               sqlite3_finalize(*stmt);
+               *stmt = NULL;
+       }
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index