From 411f911b60135ae6992ea667b1e7eeb2512af7e6 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sat, 15 Sep 2018 00:42:05 -0500 Subject: [PATCH] Bump sym file version and add a couple sanity checks. Bumping the version forces regeneration of any sym files created by old ORCA/C versions with the bug that was just fixed. A couple sanity checks are also introduced when reading sym files, including one that would have caught that bug. --- CCommon.pas | 1 + Header.pas | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CCommon.pas b/CCommon.pas index c2954be..4aded5e 100644 --- a/CCommon.pas +++ b/CCommon.pas @@ -942,6 +942,7 @@ case errnum of {print the error} 9 : msg := concat('Error writing ', objFile.theString.theString); 10: msg := 'ORCA/C requires version 2.0 or later of the shell'; 11: msg := 'The program is too large to compile to memory -- use Compile to Disk'; + 12: msg := 'Invalid sym file detected. Re-run ORCA/C to proceed.'; otherwise: begin msg := ''; Error(57); diff --git a/Header.pas b/Header.pas index 19f93a0..f701038 100644 --- a/Header.pas +++ b/Header.pas @@ -18,7 +18,7 @@ uses CCommon, MM, Scanner, Symbol, CGI; {$segment 'SCANNER'} const - symFileVersion = 2; {version number of .sym file format} + symFileVersion = 3; {version number of .sym file format} var inhibitHeader: boolean; {should .sym includes be blocked?} @@ -1647,6 +1647,7 @@ var 1: begin {read a type displacement} tdisp := typeDispList; disp := ReadLong; + tp := nil; while tdisp <> nil do if tdisp^.saveDisp = disp then begin tp := tdisp^.tPtr; @@ -1654,6 +1655,11 @@ var end {if} else tdisp := tdisp^.next; + if tp = nil then begin + PurgeSymbols; + DestroySymbolFile; + TermError(12); + end; {if} end; {case 1} 2: tp := bytePtr; @@ -1876,6 +1882,11 @@ if not ignoreSymbols then begin end; {while} DisposeTypeDispList; saveSource := false; + if ord4(symPtr) > ord4(symEndPtr) then begin + PurgeSymbols; + DestroySymbolFile; + TermError(12); + end; {if} end {if} else begin PurgeSymbols; {no file found}