Skip to content

Commit 4b31262

Browse files
committed
fix(memory): apply gc fix from moddable
1 parent 547c16c commit 4b31262

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

xs/sources/xsMemory.c

+4
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,15 @@ void fxGrowSlots(txMachine* the, txSize theCount)
567567
while (theCount--) {
568568
txSlot* next = aSlot + 1;
569569
aSlot->next = next;
570+
aSlot->flag = XS_NO_FLAG;
570571
aSlot->kind = XS_UNDEFINED_KIND;
571572
#if mxPoisonSlots
572573
ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value));
573574
#endif
574575
aSlot = next;
575576
}
576577
aSlot->next = the->freeHeap;
578+
aSlot->flag = XS_NO_FLAG;
577579
aSlot->kind = XS_UNDEFINED_KIND;
578580
#if mxPoisonSlots
579581
ASAN_POISON_MEMORY_REGION(&aSlot->value, sizeof(aSlot->value));
@@ -839,6 +841,8 @@ void fxMarkReference(txMachine* the, txSlot* theSlot)
839841
fxCheckCStack(the);
840842
if ((aSlot = theSlot->value.array.address)) {
841843
txIndex aLength = (((txChunk*)(((txByte*)aSlot) - sizeof(txChunk)))->size) / sizeof(txSlot);
844+
if (aLength > theSlot->value.array.length)
845+
aLength = theSlot->value.array.length;
842846
while (aLength) {
843847
fxMarkReference(the, aSlot);
844848
aSlot++;

0 commit comments

Comments
 (0)