Skip to content

Commit

Permalink
Fix memory leak for PNG images
Browse files Browse the repository at this point in the history
Commit 5fe1390 used an implementation
which created a new Pix object. That object was never destroyed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jan 23, 2019
1 parent daf61f7 commit 9e6e3a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/baseapi.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 9e6e3a0

Please sign in to comment.