Skip to content

Commit

Permalink
Merge pull request #184 from lukego/ctype-no-loop
Browse files Browse the repository at this point in the history
lj_ctype.c: Detect loops in ctype_repr()
  • Loading branch information
lukego committed Aug 10, 2018
2 parents 9fac632 + 3f9db9e commit 5d235e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lj_ctype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 5d235e6

Please sign in to comment.