提交 966a6521 编写于 作者: S Sam Bromley

Fix crash when polling for non-existent Kinects.

If no Kinects are present, crash can result from
stepping beyond end of device list. Now we check
to ensure this does not happen.
上级 49b55a72
......@@ -575,7 +575,12 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
// Chose device according to index
xn::NodeInfoList::Iterator it = devicesList.Begin();
for( int i = 0; i < index; ++i ) it++;
for( int i = 0; i < index && it!=devicesList.End(); ++i ) it++;
if ( it == devicesList.End() )
{
std::cerr << "CvCapture_OpenNI::CvCapture_OpenNI : Faile
return;
}
xn::NodeInfo deviceNode = *it;
status = context.CreateProductionTree( deviceNode, productionNode );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册