Skip to content

Commit 3de97ac

Browse files
committed
Fix rare FindrNumber/TermRenumber crashes when loading saves
Uncommenting this line fixes crashes when loading certain save files, where the sizes of the terms have some interaction with SizeStoreCache. Changing that value or setting NumStoreCaches to 0 is a works-around also. Closes form-dev#420 and form-dev#484
1 parent 92f3154 commit 3de97ac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sources/setfile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ int AllocSetups(VOID)
729729
AM.NumStoreCaches = sp->value;
730730
sp = GetSetupPar((UBYTE *)"sizestorecache");
731731
AM.SizeStoreCache = sp->value;
732+
/* Make sure this is a multiple of sizeof(WORD). */
733+
AM.SizeStoreCache = ((AM.SizeStoreCache+sizeof(WORD)-1)/sizeof(WORD))*sizeof(WORD);
732734
#ifndef WITHPTHREADS
733735
/*
734736
Install the store caches (15-aug-2006 JV)

sources/store.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,9 @@ PastCon:;
16951695
num = *from++;
16961696
ADDPOS(*position,sizeof(WORD));
16971697
*to += (WORD)num;
1698-
/* first = 0; */
1698+
/* This next line has always been commented, but uncommenting it
1699+
fixes a rare bug when loading certain save files. */
1700+
first = 0;
16991701
*InCompState = (WORD)(num + 2);
17001702
}
17011703
goto PastCon;

0 commit comments

Comments
 (0)