Ask Your Question

Revision history [back]

How do I fix "Returning null reference (within a call to 'at')" logic error found by Xcode 5 Analyzer?

Here's my scenario:

Using Xcode/Product/Analyze I get the following error on the value = mat.at line below:

    Logic error: Returning null reference (within a call to 'at')
int SomeFunction(const cv::Mat& mat)
{
    float value;
    for (int i=0; i<rows; i++)="" {="" for="" (int="" j-0;="" j<cols;="" j++)="" {="" value="mat.at&lt;uint8_t">(i,j);
            // code that uses the value
        }
    }
}
click to hide/show revision 2
No.2 Revision

updated 2015-02-24 11:48:19 -0600

berak gravatar image

How do I fix "Returning null reference (within a call to 'at')" logic error found by Xcode 5 Analyzer?

Here's my scenario:

Using Xcode/Product/Analyze I get the following error on the value = mat.at line below:

 Logic error: Returning null reference (within a call to 'at')
'at')
int SomeFunction(const cv::Mat& mat)
{
    float value;
    for (int i=0; i<rows; i++)="" {="" for="" (int="" j-0;="" j<cols;="" j++)="" {="" value="mat.at&lt;uint8_t">(i,j);
i++)
    {
        for (int j-0; j<cols; j++)
        {
            value = mat.at<uint8_t>(i,j);
            // code that uses the value
        }
    }
}