From 015e00bcdbffbabc3c27cb058592f0c03c2b7f5f Mon Sep 17 00:00:00 2001 From: lluis Date: Thu, 23 Jul 2015 20:01:19 +0200 Subject: [PATCH] Fix memory leak bug #4420 --- modules/text/src/ocr_tesseract.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/text/src/ocr_tesseract.cpp b/modules/text/src/ocr_tesseract.cpp index eb61c8bbc..640a7e3b9 100644 --- a/modules/text/src/ocr_tesseract.cpp +++ b/modules/text/src/ocr_tesseract.cpp @@ -140,7 +140,10 @@ public: tess.SetImage((uchar*)image.data, image.size().width, image.size().height, image.channels(), image.step1()); tess.Recognize(0); - output = string(tess.GetUTF8Text()); + char *outText; + outText = tess.GetUTF8Text(); + output = string(outText); + delete [] outText; if ( (component_rects != NULL) || (component_texts != NULL) || (component_confidences != NULL) ) {