From 9e6e3a0232dfa319c5d334d3b8a773e67bf87a18 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Wed, 23 Jan 2019 20:03:55 +0100 Subject: [PATCH] Fix memory leak for PNG images Commit 5fe1390748a15c0e445a5c57c834edff27ff2f4d used an implementation which created a new Pix object. That object was never destroyed. Signed-off-by: Stefan Weil --- src/api/baseapi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/baseapi.cpp b/src/api/baseapi.cpp index c76cab57d0..4500a83b88 100644 --- a/src/api/baseapi.cpp +++ b/src/api/baseapi.cpp @@ -613,9 +613,9 @@ void TessBaseAPI::SetImage(Pix* pix) { if (InternalSetImage()) { if (pixGetSpp(pix) == 4 && pixGetInputFormat(pix) == IFF_PNG) { // remove alpha channel from png - PIX* p1 = pixRemoveAlpha(pix); + Pix* p1 = pixRemoveAlpha(pix); pixSetSpp(p1, 3); - pix = pixCopy(nullptr, p1); + (void)pixCopy(pix, p1); pixDestroy(&p1); } thresholder_->SetImage(pix);