Commit 25d2ab8a authored by Andrey Pavlenko's avatar Andrey Pavlenko Committed by OpenCV Buildbot

Merge pull request #2218 from alalek:fix_defects_code_coverity

parents 6925dbd9 6fa49f6e
...@@ -561,6 +561,9 @@ public: ...@@ -561,6 +561,9 @@ public:
explicit PlatformInfo2(void* id); explicit PlatformInfo2(void* id);
~PlatformInfo2(); ~PlatformInfo2();
PlatformInfo2(const PlatformInfo2& i);
PlatformInfo2& operator =(const PlatformInfo2& i);
String name() const; String name() const;
String vendor() const; String vendor() const;
String version() const; String version() const;
......
...@@ -3691,6 +3691,7 @@ struct PlatformInfo2::Impl ...@@ -3691,6 +3691,7 @@ struct PlatformInfo2::Impl
{ {
Impl(void* id) Impl(void* id)
{ {
refcount = 1;
handle = *(cl_platform_id*)id; handle = *(cl_platform_id*)id;
getDevices(devices, handle); getDevices(devices, handle);
} }
...@@ -3724,6 +3725,26 @@ PlatformInfo2::~PlatformInfo2() ...@@ -3724,6 +3725,26 @@ PlatformInfo2::~PlatformInfo2()
p->release(); p->release();
} }
PlatformInfo2::PlatformInfo2(const PlatformInfo2& i)
{
if (i.p)
i.p->addref();
this->p = i.p;
}
PlatformInfo2& PlatformInfo2::operator =(const PlatformInfo2& i)
{
if (i.p != this->p)
{
if (i.p)
i.p->addref();
if (this->p)
this->p->release();
this->p = i.p;
}
return *this;
}
int PlatformInfo2::deviceNumber() const int PlatformInfo2::deviceNumber() const
{ {
return p ? (int)p->devices.size() : 0; return p ? (int)p->devices.size() : 0;
...@@ -3731,7 +3752,7 @@ int PlatformInfo2::deviceNumber() const ...@@ -3731,7 +3752,7 @@ int PlatformInfo2::deviceNumber() const
void PlatformInfo2::getDevice(Device& device, int d) 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) if(p)
device.set(p->devices[d]); device.set(p->devices[d]);
} }
......
...@@ -398,7 +398,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual ...@@ -398,7 +398,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1minMaxLocManual
return result; return result;
} catch(cv::Exception e) { } catch(const cv::Exception& e) {
LOGD("Core::n_1minMaxLoc() catched cv::Exception: %s", e.what()); LOGD("Core::n_1minMaxLoc() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException"); jclass je = env->FindClass("org/opencv/core/CvException");
if(!je) je = env->FindClass("java/lang/Exception"); if(!je) je = env->FindClass("java/lang/Exception");
...@@ -471,7 +471,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize ...@@ -471,7 +471,7 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
return result; return result;
} catch(cv::Exception e) { } catch(const cv::Exception& e) {
LOGD("Core::n_1getTextSize() catched cv::Exception: %s", e.what()); LOGD("Core::n_1getTextSize() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException"); jclass je = env->FindClass("org/opencv/core/CvException");
if(!je) je = env->FindClass("java/lang/Exception"); if(!je) je = env->FindClass("java/lang/Exception");
......
...@@ -467,7 +467,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims ...@@ -467,7 +467,7 @@ JNIEXPORT jint JNICALL Java_org_opencv_core_Mat_n_1dims
LOGD("%s", method_name); LOGD("%s", method_name);
Mat* me = (Mat*) self; //TODO: check for NULL Mat* me = (Mat*) self; //TODO: check for NULL
return me->dims; return me->dims;
} catch(cv::Exception e) { } catch(const cv::Exception& e) {
throwJavaException(env, &e, method_name); throwJavaException(env, &e, method_name);
} catch (...) { } catch (...) {
throwJavaException(env, 0, method_name); throwJavaException(env, 0, method_name);
......
...@@ -48,7 +48,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nBitmapToMat2 ...@@ -48,7 +48,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nBitmapToMat2
} }
AndroidBitmap_unlockPixels(env, bitmap); AndroidBitmap_unlockPixels(env, bitmap);
return; return;
} catch(cv::Exception e) { } catch(const cv::Exception& e) {
AndroidBitmap_unlockPixels(env, bitmap); AndroidBitmap_unlockPixels(env, bitmap);
LOGE("nBitmapToMat catched cv::Exception: %s", e.what()); LOGE("nBitmapToMat catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException"); jclass je = env->FindClass("org/opencv/core/CvException");
...@@ -130,7 +130,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nMatToBitmap2 ...@@ -130,7 +130,7 @@ JNIEXPORT void JNICALL Java_org_opencv_android_Utils_nMatToBitmap2
} }
AndroidBitmap_unlockPixels(env, bitmap); AndroidBitmap_unlockPixels(env, bitmap);
return; return;
} catch(cv::Exception e) { } catch(const cv::Exception& e) {
AndroidBitmap_unlockPixels(env, bitmap); AndroidBitmap_unlockPixels(env, bitmap);
LOGE("nMatToBitmap catched cv::Exception: %s", e.what()); LOGE("nMatToBitmap catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException"); jclass je = env->FindClass("org/opencv/core/CvException");
......
...@@ -598,6 +598,7 @@ namespace cv ...@@ -598,6 +598,7 @@ namespace cv
struct dim3 struct dim3
{ {
unsigned int x, y, z; unsigned int x, y, z;
dim3() : x(0), y(0), z(0) { }
}; };
public: public:
PyrLKOpticalFlow() PyrLKOpticalFlow()
...@@ -607,6 +608,8 @@ namespace cv ...@@ -607,6 +608,8 @@ namespace cv
iters = 30; iters = 30;
derivLambda = 0.5; derivLambda = 0.5;
useInitialFlow = false; useInitialFlow = false;
waveSize = 0;
} }
bool checkParam() bool checkParam()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment