diff options
| author | Mike Pall <mike> | 2021-06-25 12:45:51 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2021-06-25 12:45:51 +0200 |
| commit | 16d38a4b214e8b8a20be554be77bd20286072365 (patch) | |
| tree | 6b14e9680a3bb61306fc16fb28984ccf03f5380d /src | |
| parent | 3f9389edc6cdf3f78a6896d550c236860aed62b2 (diff) | |
| download | luajit-16d38a4b214e8b8a20be554be77bd20286072365.tar.gz luajit-16d38a4b214e8b8a20be554be77bd20286072365.tar.bz2 luajit-16d38a4b214e8b8a20be554be77bd20286072365.zip | |
Avoid conflict between 64 bit lightuserdata and ITERN key.
Reported by XmiliaH.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_udata.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lj_udata.c b/src/lj_udata.c index b2ea8031..a0edd0df 100644 --- a/src/lj_udata.c +++ b/src/lj_udata.c | |||
| @@ -47,9 +47,10 @@ void *lj_lightud_intern(lua_State *L, void *p) | |||
| 47 | if (segmap[seg] == up) /* Fast path. */ | 47 | if (segmap[seg] == up) /* Fast path. */ |
| 48 | return (void *)(((uint64_t)seg << LJ_LIGHTUD_BITS_LO) | lightudlo(u)); | 48 | return (void *)(((uint64_t)seg << LJ_LIGHTUD_BITS_LO) | lightudlo(u)); |
| 49 | segnum++; | 49 | segnum++; |
| 50 | /* Leave last segment unused to avoid clash with ITERN key. */ | ||
| 51 | if (segnum >= (1 << LJ_LIGHTUD_BITS_SEG)-1) lj_err_msg(L, LJ_ERR_BADLU); | ||
| 50 | } | 52 | } |
| 51 | if (!((segnum-1) & segnum) && segnum != 1) { | 53 | if (!((segnum-1) & segnum) && segnum != 1) { |
| 52 | if (segnum >= (1 << LJ_LIGHTUD_BITS_SEG)) lj_err_msg(L, LJ_ERR_BADLU); | ||
| 53 | lj_mem_reallocvec(L, segmap, segnum, segnum ? 2*segnum : 2u, uint32_t); | 54 | lj_mem_reallocvec(L, segmap, segnum, segnum ? 2*segnum : 2u, uint32_t); |
| 54 | setmref(g->gc.lightudseg, segmap); | 55 | setmref(g->gc.lightudseg, segmap); |
| 55 | } | 56 | } |
