fixes for defects from code coverity
authorAlexander Alekhin <alexander.alekhin@itseez.com>
Tue, 28 Jan 2014 16:22:56 +0000 (20:22 +0400)
committerAlexander Alekhin <alexander.alekhin@itseez.com>
Tue, 28 Jan 2014 16:24:10 +0000 (20:24 +0400)
modules/core/src/ocl.cpp
modules/imgproc/src/filter.cpp
modules/java/generator/gen_java.py
modules/java/generator/src/cpp/Mat.cpp
modules/java/generator/src/cpp/utils.cpp

index 7201fca..1a2714d 100644 (file)
@@ -3673,6 +3673,7 @@ struct PlatformInfo2::Impl
 {
     Impl(void* id)
     {
+        refcount = 1;
         handle = *(cl_platform_id*)id;
         getDevices(devices, handle);
     }
@@ -3713,7 +3714,7 @@ int PlatformInfo2::deviceNumber() const
 
 void PlatformInfo2::getDevice(Device& device, int d) const
 {
-    CV_Assert(d < (int)p->devices.size() );
+    CV_Assert(p && d < (int)p->devices.size() );
     if(p)
         device.set(p->devices[d]);
 }
index 8c11c62..d644f23 100644 (file)
@@ -3508,7 +3508,7 @@ static bool ocl_sepFilter2D( InputArray _src, OutputArray _dst, int ddepth,
 
     int type = _src.type();
     if ( !( (CV_8UC1 == type || CV_8UC4 == type || CV_32FC1 == type || CV_32FC4 == type) &&
-            (ddepth == CV_32F || ddepth == CV_8U) ) )
+            (ddepth == CV_32F || ddepth == CV_8U || ddepth < 0) ) )
         return false;
 
     int cn = CV_MAT_CN(type);
index 23ed3a9..cce2708 100755 (executable)
@@ -398,7 +398,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual
 
     return result;
 
-    } catch(cv::Exception e) {
+    } catch(const cv::Exception& e) {
         LOGD("Core::n_1minMaxLoc() catched cv::Exception: %s", e.what());
         jclass je = env->FindClass("org/opencv/core/CvException");
         if(!je) je = env->FindClass("java/lang/Exception");
@@ -471,7 +471,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
 
         return result;
 
-    } catch(cv::Exception e) {
+    } catch(const cv::Exception& e) {
         LOGD("Core::n_1getTextSize() catched cv::Exception: %s", e.what());
         jclass je = env->FindClass("org/opencv/core/CvException");
         if(!je) je = env->FindClass("java/lang/Exception");
index b3b0f66..185cb2d 100644 (file)
@@ -467,7 +467,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
         LOGD("%s", method_name);
         Mat* me = (Mat*) self; //TODO: check for NULL
         return me->dims;
-    } catch(cv::Exception e) {
+    } catch(const cv::Exception& e) {
         throwJavaException(env, &e, method_name);
     } catch (...) {
         throwJavaException(env, 0, method_name);
index 40811e8..2d409c8 100644 (file)
@@ -48,7 +48,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nBitmapToMat2
             }
             AndroidBitmap_unlockPixels(env, bitmap);
             return;
-        } catch(cv::Exception e) {
+        } catch(const cv::Exception& e) {
             AndroidBitmap_unlockPixels(env, bitmap);
             LOGE("nBitmapToMat catched cv::Exception: %s", e.what());
             jclass je = env->FindClass("org/opencv/core/CvException");
@@ -130,7 +130,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nMatToBitmap2
             }
             AndroidBitmap_unlockPixels(env, bitmap);
             return;
-        } catch(cv::Exception e) {
+        } catch(const cv::Exception& e) {
             AndroidBitmap_unlockPixels(env, bitmap);
             LOGE("nMatToBitmap catched cv::Exception: %s", e.what());
             jclass je = env->FindClass("org/opencv/core/CvException");