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 3472
const SGM_REPLACE = 1 shl 0;