Skip to content

Commit

Permalink
Merge pull request #2021 from stweil/lgtm
Browse files Browse the repository at this point in the history
tesseractmain: Fix memory leak
  • Loading branch information
zdenop committed Oct 22, 2018
2 parents 55704d2 + be0cf03 commit 69a2e94
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/tesseractmain.cpp
Expand Up @@ -413,6 +413,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create hOCR output file: %s\n",
strerror(errno));
}
Expand All @@ -427,6 +428,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create TSV output file: %s\n",
strerror(errno));
}
Expand All @@ -446,6 +448,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create PDF output file: %s\n",
strerror(errno));
}
Expand All @@ -458,6 +461,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create UNLV output file: %s\n",
strerror(errno));
}
Expand All @@ -470,6 +474,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create BOX output file: %s\n",
strerror(errno));
}
Expand All @@ -482,6 +487,7 @@ static void PreloadRenderers(
if (renderer->happy()) {
renderers->push_back(renderer);
} else {
delete renderer;
tprintf("Error, could not create TXT output file: %s\n",
strerror(errno));
}
Expand Down

6 comments on commit 69a2e94

@egorpugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tesseract::TessHOcrRenderer* renderer must be std::unique_ptr<tesseract::TessHOcrRenderer> renderer.
It's C++11 time.

@stweil
Copy link
Contributor

@stweil stweil commented on 69a2e94 Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, but it would require much more changes, as renderer is pushed to renderers.

@egorpugin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
Let's think this is for the future release. :)

@amitdo
Copy link
Collaborator

@amitdo amitdo commented on 69a2e94 Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's C++11 time.

Maybe it's C++14 time? :-)

@egorpugin
Copy link
Contributor

@egorpugin egorpugin commented on 69a2e94 Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's C++14 time? :-)

In this case it's definitely C++17 time.

@amitdo
Copy link
Collaborator

@amitdo amitdo commented on 69a2e94 Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++17 is still too new. Wait for at least 2 years... :(

It will probably be okay to move to C++14 sometime in the next 12 months.

Please sign in to comment.