Why my code loead to Runtime error?

The following is my code, and I have written some other code to run all test-cases, everything works fine on my computer! But when I commit, it lead to Runtime Error:
image

// morris traverse
class Solution {
   public:
    bool isValidBST(TreeNode* root) {
        int64_t vlast = INT64_MIN;
        TreeNode* curr = root;
        TreeNode* predecessor = nullptr;
        while (curr != nullptr) {
            predecessor = curr->left;
            if (predecessor != nullptr) {
                while (predecessor->right != nullptr && predecessor->right != curr) {
                    predecessor = predecessor->right;
                }
                if (predecessor->right == nullptr) {
                    predecessor->right = curr;
                    curr = curr->left;
                } else {
                    predecessor->right = nullptr;

                    if (curr->val <= vlast) return false;
                    vlast = curr->val;

                    curr = curr->right;
                }
            } else {
                if (curr->val <= vlast) return false;
                vlast = curr->val;

                curr = curr->right;
            }
        }

        return true;
    }
};

Any help appreciated!.
My full code is here:
https://github.com/uniqss/leetcodecpp/blob/master/98_ValidateBinarySearchTree/98_ValidateBinarySearchTree3.cpp

Comments (2)