From 7d8e5f623a9f1f971c45aa4912dc4679f5165f43 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Wed, 12 Nov 2014 17:00:08 +0300 Subject: [PATCH] Fix uninitialized memory reads and memory leaks in StereoGC --- modules/legacy/src/stereogc.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/legacy/src/stereogc.cpp b/modules/legacy/src/stereogc.cpp index 42466a0635..62857a656b 100644 --- a/modules/legacy/src/stereogc.cpp +++ b/modules/legacy/src/stereogc.cpp @@ -157,7 +157,10 @@ static int64 icvGCMaxFlow( GCVtx* vtx, int nvtx, GCEdge* edges, GCVtx**& _orphan v->t = v->weight < 0; } else + { + v->next = NULL; v->parent = 0; + } } first = first->next; @@ -396,6 +399,8 @@ void cvReleaseStereoGCState( CvStereoGCState** _state ) cvReleaseMat( &state->right ); cvReleaseMat( &state->ptrLeft ); cvReleaseMat( &state->ptrRight ); + cvReleaseMat( &state->dispLeft ); + cvReleaseMat( &state->dispRight ); cvReleaseMat( &state->vtxBuf ); cvReleaseMat( &state->edgeBuf ); cvFree( _state );