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

asked 2015-02-24 11:44:58 -0600

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

berak gravatar image

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<uint8_t>(i,j);
            // code that uses the value
        }
    }
}
edit retag flag offensive close merge delete