Add check before using it to avoid access violation.