From 7a6475c3f9450cd03e69edb67403a747edf8a563 Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Mon, 28 Jan 2013 16:51:28 -0500 Subject: [PATCH] Check pointers before using them in var init --- modules/calib3d/src/posit.cpp | 12 ++++++------ modules/core/src/persistence.cpp | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/modules/calib3d/src/posit.cpp b/modules/calib3d/src/posit.cpp index 61f86a03eb..c8c1c2c2f1 100644 --- a/modules/calib3d/src/posit.cpp +++ b/modules/calib3d/src/posit.cpp @@ -119,12 +119,6 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints, float diff = (float)criteria.epsilon; float inv_focalLength = 1 / focalLength; - /* init variables */ - int N = pObject->N; - float *objectVectors = pObject->obj_vecs; - float *invMatrix = pObject->inv_matr; - float *imgVectors = pObject->img_vecs; - /* Check bad arguments */ if( imagePoints == NULL ) return CV_NULLPTR_ERR; @@ -143,6 +137,12 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints, if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 ) return CV_BADFACTOR_ERR; + /* init variables */ + int N = pObject->N; + float *objectVectors = pObject->obj_vecs; + float *invMatrix = pObject->inv_matr; + float *imgVectors = pObject->img_vecs; + while( !converged ) { if( count == 0 ) diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 99d46c298c..a16b63e135 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -614,11 +614,12 @@ cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing CvStringHashNode* node = 0; unsigned hashval = 0; int i, tab_size; - CvStringHash* map = fs->str_hash; if( !fs ) return 0; + CvStringHash* map = fs->str_hash; + if( len < 0 ) { for( i = 0; str[i] != '\0'; i++ )