diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 32bbaedf..eb7ea038 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -390,7 +390,7 @@ static int smlua__get_field(lua_State* L) { // Legacy support if (strcmp(key, "_pointer") == 0) { - lua_pushinteger(L, (u64)(intptr_t) cobj->pointer); + lua_pushinteger(L, pointer); return 1; } if (strcmp(key, "_lot") == 0) { @@ -554,7 +554,7 @@ int smlua__gc(lua_State *L) { if (!cobj->freed) { switch (cobj->lot) { case LOT_SURFACE: { - smlua_pointer_user_data_delete((u64)(intptr_t) cobj->pointer); + smlua_pointer_user_data_delete((uintptr_t) cobj->pointer); } } } diff --git a/src/pc/lua/smlua_cobject_map.c b/src/pc/lua/smlua_cobject_map.c index 2708dd51..d0bf5128 100644 --- a/src/pc/lua/smlua_cobject_map.c +++ b/src/pc/lua/smlua_cobject_map.c @@ -12,7 +12,7 @@ void smlua_pointer_user_data_init(void) { smlua_pointer_user_data_shutdown(); } -void smlua_pointer_user_data_add(u64 pointer, CObject *obj) { +void smlua_pointer_user_data_add(uintptr_t pointer, CObject *obj) { if (pointer == 0) { return; } if (!sPointers) { @@ -24,12 +24,12 @@ void smlua_pointer_user_data_add(u64 pointer, CObject *obj) { } } -void smlua_pointer_user_data_delete(u64 pointer) { +void smlua_pointer_user_data_delete(uintptr_t pointer) { if (pointer == 0) { return; } hmap_del(sPointers, pointer); } -CObject *smlua_pointer_user_data_get(u64 pointer) { +CObject *smlua_pointer_user_data_get(uintptr_t pointer) { if (pointer == 0) { return NULL; } return hmap_get(sPointers, pointer); } diff --git a/src/pc/lua/smlua_cobject_map.h b/src/pc/lua/smlua_cobject_map.h index 1bbf9c96..e5e22a37 100644 --- a/src/pc/lua/smlua_cobject_map.h +++ b/src/pc/lua/smlua_cobject_map.h @@ -3,8 +3,8 @@ void smlua_pointer_user_data_init(void); void smlua_pointer_user_data_shutdown(void); -void smlua_pointer_user_data_add(u64 pointer, CObject *obj); -void smlua_pointer_user_data_delete(u64 pointer); -CObject *smlua_pointer_user_data_get(u64 pointer); +void smlua_pointer_user_data_add(uintptr_t pointer, CObject *obj); +void smlua_pointer_user_data_delete(uintptr_t pointer); +CObject *smlua_pointer_user_data_get(uintptr_t pointer); #endif diff --git a/src/pc/lua/smlua_utils.c b/src/pc/lua/smlua_utils.c index 499d8926..9ae8d8ec 100644 --- a/src/pc/lua/smlua_utils.c +++ b/src/pc/lua/smlua_utils.c @@ -364,7 +364,7 @@ void smlua_push_object(lua_State* L, u16 lot, void* p) { switch (lot) { case LOT_SURFACE: { - smlua_pointer_user_data_add((u64)(intptr_t) p, cobject); + smlua_pointer_user_data_add((uintptr_t) p, cobject); } } } @@ -735,10 +735,10 @@ void smlua_logline(void) { // Lua is able to use-after-free that pointer void smlua_free(void *ptr) { if (ptr && gLuaState) { - CObject *obj = smlua_pointer_user_data_get((u64)(intptr_t) ptr); + CObject *obj = smlua_pointer_user_data_get((uintptr_t) ptr); if (obj) { obj->freed = true; - smlua_pointer_user_data_delete((u64)(intptr_t) ptr); + smlua_pointer_user_data_delete((uintptr_t) ptr); } } free(ptr);