LEETCODE PROBLEM

(- LeetCode)
Can someone please tell me where am I going wrong?
It returns negative value in some cases

long long int sum=0;
int binaryToDecimal(long long int n)
{
    int num = n;
    int dec_value = 0;
    int base = 1;
    int temp = num;
    while (temp) {
        int last_digit = temp % 10;
        temp = temp / 10;
        dec_value += last_digit * base;
        base = base * 2;
    }    
    return dec_value;
}
void fun(TreeNode *root,long long int v)
{
    if(root==NULL)
        return;
    v=v*10;
    v+=root->val;
    if(root->left==NULL&&root->right==NULL)
    {
        sum=sum+binaryToDecimal(v);
        return;
    }
    fun(root->left,v);
    fun(root->right,v);
}
int sumRootToLeaf(TreeNode* root) 
{
    int v=0;
    fun(root,0);
    return sum;
}

Which cases?

[1,0,1,0,1,1,0,1,0,0,0,1,0,0,0,0,1,1,0,null,1,0,null,1,1,1,1,null,0,null,null,null,null,null,null,1,null,0,null,null,null,null,null,0,1,1,0,0,0,0,null,null,null,0,null,null,null,0,null,0,null,null,null,null,1,null,null,0,0,0,null,null,null,1,null,null,null,0,0,null,null,null,null,null,0,null,null,null,null,1,null,null,null,0,1,null,0]

Expected output is 4433 nd my output is -1423