That is valid only if a cursor UI element (which is separate from the OS cursor) has actually been set by the application. You should be able to avoid the crash by nullchecking.
Controlling the OS mouse cursor visibility happens through the Input subsystem -> Input::SetMouseVisible().