lua-users home
lua-l archive

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


Hi,

I think there's a bug in the LuaSQLite3 library (Version "0.7-devel").

In function dbvm_bind_names() the stack is not pop-ed so it will crash if
there are > 20 parameters:

        if (name && (name[0] == ':' || name[0] == '$')) {
            lua_pushstring(L, ++name);
            lua_gettable(L, 2);
            result = dbvm_bind_index(L, vm, n, -1);
		lua_pop(L, 1);	// Fix
        }

Some other improvements:

	* dbvm_bind_index() should bind a double only if necessary:

        case LUA_TNUMBER:
			{
				lua_Number n = lua_tonumber(L, lindex);
				sqlite_int64 i64 = (sqlite_int64)n;
				if (n == (lua_Number)i64)	// Is
integer?
					return sqlite3_bind_int64(vm, index,
i64);
				else
					return sqlite3_bind_double(vm,
index, n);
			}
			break;

	* I think dbvm_bind_index() should bind boolean as 1 or 0 (and not
as null)

        case LUA_TNONE:
        case LUA_TNIL:
			return sqlite3_bind_null(vm, index);
        case LUA_TBOOLEAN:
			return sqlite3_bind_int(vm, index, lua_toboolean(L,
lindex)?1:0);


Regards,

Ronny Dierckx