aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2022-01-15 18:32:34 +0100
committerMike Pall <mike>2022-01-15 18:32:34 +0100
commitc21c6cb4170159250aa778ec888db7f919dfb0e9 (patch)
treed00555bb8692351df0c486f8cca0f6df77f7e5b4
parentd5a237eae03d2ad346f82390836371a952e9a286 (diff)
downloadluajit-c21c6cb4170159250aa778ec888db7f919dfb0e9.tar.gz
luajit-c21c6cb4170159250aa778ec888db7f919dfb0e9.tar.bz2
luajit-c21c6cb4170159250aa778ec888db7f919dfb0e9.zip
FFI: Ensure library is loaded before de-serializing FFI types.
Reported by ImagicTheCat.
-rw-r--r--doc/ext_buffer.html4
-rw-r--r--src/lj_serialize.c1
2 files changed, 5 insertions, 0 deletions
diff --git a/doc/ext_buffer.html b/doc/ext_buffer.html
index 63c2efe3..309b496b 100644
--- a/doc/ext_buffer.html
+++ b/doc/ext_buffer.html
@@ -448,6 +448,10 @@ encoded data. The stand-alone function throws when there's left-over
448data after decoding a single top-level object. The buffer method leaves 448data after decoding a single top-level object. The buffer method leaves
449any left-over data in the buffer. 449any left-over data in the buffer.
450</p> 450</p>
451<p>
452Attempting to de-serialize an FFI type will throw an error, if the FFI
453library is not built-in or has not been loaded, yet.
454</p>
451 455
452<h3 id="serialize_options">Serialization Options</h3> 456<h3 id="serialize_options">Serialization Options</h3>
453<p> 457<p>
diff --git a/src/lj_serialize.c b/src/lj_serialize.c
index d6551b11..d00bf7fa 100644
--- a/src/lj_serialize.c
+++ b/src/lj_serialize.c
@@ -417,6 +417,7 @@ static char *serialize_get(char *r, SBufExt *sbx, TValue *o)
417 uint32_t sz = tp == SER_TAG_COMPLEX ? 16 : 8; 417 uint32_t sz = tp == SER_TAG_COMPLEX ? 16 : 8;
418 GCcdata *cd; 418 GCcdata *cd;
419 if (LJ_UNLIKELY(r + sz > w)) goto eob; 419 if (LJ_UNLIKELY(r + sz > w)) goto eob;
420 if (LJ_UNLIKELY(!ctype_ctsG(G(sbufL(sbx))))) goto badtag;
420 cd = lj_cdata_new_(sbufL(sbx), 421 cd = lj_cdata_new_(sbufL(sbx),
421 tp == SER_TAG_INT64 ? CTID_INT64 : 422 tp == SER_TAG_INT64 ? CTID_INT64 :
422 tp == SER_TAG_UINT64 ? CTID_UINT64 : CTID_COMPLEX_DOUBLE, 423 tp == SER_TAG_UINT64 ? CTID_UINT64 : CTID_COMPLEX_DOUBLE,