[4.0] Add the protected code and fix the crash issue