在查找二叉树的高度时,这两个语句的差异 b/w?

Difference b/w these 2 statements while finding height of binary tree?

如果我在这里做错了什么,请告诉我。
在查找二叉树的高度时,我无法理解这两个语句之间的区别。

if (root==NULL)   return -1;  

if (root->left==NULL && root->right==NULL)  return 0;

第一个语句给出了准确的结果,但如果我使用第二个语句,则会抛出此错误“进程返回 -1073741819 (0xC0000005) 执行时间:2.195 秒”。

代码如下:

int bstHeight(bstNode* root)
{
    //if (root==NULL)   return -1;
    //if (root->left==NULL && root->right==NULL) return 0;

    else
    {
        int lh = bstHeight(root->left);
        int rh = bstHeight(root->right);
        return (lh>rh)? lh+1:rh+1;
    }
}

第一个通过左右递归直接和间接地在根中的任何地方防止 NULL。
第二个容易受到 root 为 NULL 的攻击,它可能会引用 NULL,这可能会让您看到观察到的错误消息。