You want to check whether `MCStringsExecReplace` failed - as it was done before.
You are using a MCStringRef,  after you created it, don't forget to release it before returning