]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Fix ffi.metatype() for non-raw types.
authorMike Pall <mike>
Sat, 8 Jul 2023 17:30:56 +0000 (19:30 +0200)
committerMike Pall <mike>
Sat, 8 Jul 2023 17:30:56 +0000 (19:30 +0200)
Reported by 999pingGG. #1005

src/lib_ffi.c

index 654e71a289370c753604262e3b40502d939ca8bd..3978a83e4e845a0fd10400ec550a2835daf3b17a 100644 (file)
@@ -749,7 +749,7 @@ LJLIB_CF(ffi_metatype)
   if (!(ctype_isstruct(ct->info) || ctype_iscomplex(ct->info) ||
        ctype_isvector(ct->info)))
     lj_err_arg(L, 1, LJ_ERR_FFI_INVTYPE);
-  tv = lj_tab_setinth(L, t, -(int32_t)id);
+  tv = lj_tab_setinth(L, t, -(int32_t)ctype_typeid(cts, ct));
   if (!tvisnil(tv))
     lj_err_caller(L, LJ_ERR_PROTMT);
   settabV(L, tv, mt);