eris: fix subtle GC-related bug in table sequence patch

This commit is contained in:
2021-12-09 13:54:44 -05:00
parent 2e6a3ab74e
commit a599e07cc6

View File

@@ -424,12 +424,6 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
/* create new hash part with appropriate size */
setnodevector(L, t, nhsize);
nhsize = truesizenode(t);
/* resize the sequence array */
int oldseqlen = oldasize + oldhsize;
int newseqlen = nasize + nhsize;
if (newseqlen < t->nnkeys)
luaG_runerror(L, "table sequence vector not large enough?");
luaM_reallocvector(L, t->sequence, oldseqlen, newseqlen, int);
/* possibly shrink the array part */
if (nasize < oldasize) {
t->sizearray = nasize;
@@ -453,6 +447,10 @@ void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize) {
/* delete the old node vector */
if (!isdummy(nold))
luaM_freearray(L, nold, cast(size_t, oldhsize));
/* resize the sequence array */
int oldseqlen = oldasize + oldhsize;
int newseqlen = nasize + nhsize;
luaM_reallocvector(L, t->sequence, oldseqlen, newseqlen, int);
/* recalculate the entire sequence vector */
int total = 0;
for (i = nasize - 1; i >= 0; i--) {
@@ -699,6 +697,7 @@ void luaH_setnil(Table *t, ANode *anode) {
** barrier and invalidate the TM cache.
*/
void luaH_setupdate (lua_State *L, Table *t, const TValue *key, TValue *value, const TValue *getres) {
checksequence(t);
if (!ttisnil(getres)) {
if (ttisnil(value)) {
/* replacing a non-nil value with nil */