From 3f9db9e3f6a6484684837e7e7a339fedad43c06b Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Thu, 9 Aug 2018 09:27:35 +0000 Subject: [PATCH] lj_ctype.c: Detect loops in ctype_repr() --- src/lj_ctype.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lj_ctype.c b/src/lj_ctype.c index 86abbbc146..eaccb781c0 100644 --- a/src/lj_ctype.c +++ b/src/lj_ctype.c @@ -447,6 +447,7 @@ static void ctype_repr(CTRepr *ctr, CTypeID id) for (;;) { CTInfo info = ct->info; CTSize size = ct->size; + CType *newct; switch (ctype_type(info)) { case CT_NUM: if ((info & CTF_BOOL)) { @@ -532,7 +533,13 @@ static void ctype_repr(CTRepr *ctr, CTypeID id) ctr->ok = 0; return; } - ct = ctype_get(ctr->cts, ctype_cid(info)); + newct = ctype_get(ctr->cts, ctype_cid(info)); + /* Detect ctypes that are not OK due to looping. */ + if (newct == ct) { + ctr->ok = 0; + return; + } + ct = newct; } }