[Patch] Fix crash in fptemplate (when build with -Cr)
If you build fptemplate with range checks enabled, it will crash:
c:\FPC\fpc_3.3.1\32\cr_gw\bin\i386-win32\fpcmkcfg.exe -d "basepath=c:\FPC\fpc_3.3.1\32\cr_gw" -o "c:\FPC\fpc_3.3.1\32\cr_gw\bin\i386-win32\fpc.cfg"
An unhandled exception occurred at $00463455:
ERangeError: Range check error
$00463455 INTPARSESTRING, line 546 of fcl-base/src/fptemplate.pp
$00462D28 PARSESTRING, line 452 of fcl-base/src/fptemplate.pp
$0040372D CREATEFILE, line 571 of fpcmkcfg/fpcmkcfg.pp
$004037DA main, line 583 of fpcmkcfg/fpcmkcfg.pp
This happens because in AddToString() S[Slen+1] is accessed, as it is the point of insertion for the Move() operation.
However if NChars is zero, SLen+1 is > Length(S). If Range checking is off, this does not really matter, since the Move() operation in this case does nothing (and S[Slen+1] is the terminating zero char).
Patch attached. fptemplate-addtostring.diff