From 1564fe9a83958cb3d420b8657e46af7ba31f1407 Mon Sep 17 00:00:00 2001 From: Alexander Reshetnikov Date: Thu, 29 Mar 2012 12:20:06 +0000 Subject: [PATCH] Fixed segfault problem with cap_unicap (ticket #1112) --- modules/highgui/src/cap_unicap.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/highgui/src/cap_unicap.cpp b/modules/highgui/src/cap_unicap.cpp index b195aaa..15d96e7 100644 --- a/modules/highgui/src/cap_unicap.cpp +++ b/modules/highgui/src/cap_unicap.cpp @@ -149,12 +149,15 @@ bool CvCapture_Unicap::initDevice() { } int i; - for (i = format.size_count - 1; i > 0; i--) - if (format.sizes[i].width == desired_size.width && - format.sizes[i].height == desired_size.height) - break; - format.size.width = format.sizes[i].width; - format.size.height = format.sizes[i].height; + if (format.sizes) + { + for (i = format.size_count - 1; i > 0; i--) + if (format.sizes[i].width == desired_size.width && + format.sizes[i].height == desired_size.height) + break; + format.size.width = format.sizes[i].width; + format.size.height = format.sizes[i].height; + } if (!SUCCESS(unicap_set_format(handle, &format))) { shutdownDevice(); -- 2.7.4