mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
main: Fix two memory leaks
When Tesseract terminates by calling the exit function, the destructor of any local auto variable is not called. Fix two cases by using static variables. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
af212af89f
commit
f37f858c99
@ -424,7 +424,9 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
PERF_COUNT_START("Tesseract:main")
|
||||
tesseract::TessBaseAPI api;
|
||||
|
||||
// Avoid memory leak caused by auto variable when exit() is called.
|
||||
static tesseract::TessBaseAPI api;
|
||||
|
||||
api.SetOutputName(outputbase);
|
||||
|
||||
@ -493,7 +495,8 @@ int main(int argc, char** argv) {
|
||||
(api.GetBoolVariable("tessedit_resegment_from_boxes", &b) && b) ||
|
||||
(api.GetBoolVariable("tessedit_make_boxes_from_boxes", &b) && b);
|
||||
|
||||
tesseract::PointerVector<tesseract::TessResultRenderer> renderers;
|
||||
// Avoid memory leak caused by auto variable when exit() is called.
|
||||
static tesseract::PointerVector<tesseract::TessResultRenderer> renderers;
|
||||
|
||||
if (in_training_mode) {
|
||||
renderers.push_back(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user