Mode for TSGWork.Mode replace mode please initialize StringInfo with in-range value of BufferPos if you are using SGM_REPLACE mode.
Source position: intuition.pas line 2414
const SGM_REPLACE = 1 shl 0;