diff --git a/modules/core/src/persistence.cpp b/modules/core/src/persistence.cpp index 5c8fd2f97f..002ff01d09 100644 --- a/modules/core/src/persistence.cpp +++ b/modules/core/src/persistence.cpp @@ -2651,7 +2651,6 @@ CV_IMPL CvFileStorage* cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, const char* encoding ) { CvFileStorage* fs = 0; - char* xml_buf = 0; int default_block_size = 1 << 18; bool append = (flags & 3) == CV_STORAGE_APPEND; bool mem = (flags & CV_STORAGE_MEMORY) != 0; @@ -2790,7 +2789,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co int last_occurence = -1; xml_buf_size = MIN(xml_buf_size, int(file_size)); fseek( fs->file, -xml_buf_size, SEEK_END ); - xml_buf = (char*)cvAlloc( xml_buf_size+2 ); + char* xml_buf = (char*)cvAlloc( xml_buf_size+2 ); // find the last occurence of for(;;) { @@ -2808,6 +2807,7 @@ cvOpenFileStorage( const char* filename, CvMemStorage* dststorage, int flags, co ptr += strlen(substr); } } + cvFree( &xml_buf ); if( last_occurence < 0 ) { cvReleaseFileStorage( &fs ); @@ -2922,7 +2922,6 @@ _exit_: } } - cvFree( &xml_buf ); return fs; }