I suggest `cv::AutoBuffer<float> buf(required + 1);` instead;