diff --git a/src/ls_mysql.c b/src/ls_mysql.c index f6e2438..f4d3908 100644 --- a/src/ls_mysql.c +++ b/src/ls_mysql.c @@ -339,7 +339,7 @@ static int cur_close (lua_State *L) { ** a reference to it on the cursor structure. */ static void _pushtable (lua_State *L, cur_data *cur, size_t off) { - int *ref = (int *)((char *)cur + off); + int *ref = (int *)cur + off / sizeof(int); /* If colnames or coltypes do not exist, create both. */ if (*ref == LUA_NOREF) diff --git a/src/ls_postgres.c b/src/ls_postgres.c index fb4f9e2..f952bcd 100644 --- a/src/ls_postgres.c +++ b/src/ls_postgres.c @@ -248,7 +248,7 @@ static void create_coltypes (lua_State *L, cur_data *cur) { ** a reference to it on the cursor structure. */ static void _pushtable (lua_State *L, cur_data *cur, size_t off, creator func) { - int *ref = (int *)((char *)cur + off); + int *ref = (int *)cur + off / sizeof(int); if (*ref != LUA_NOREF) lua_rawgeti (L, LUA_REGISTRYINDEX, *ref); else {