Replace memcpy with memmove in replace_string().
Fix buffer underun in restore_object()