Skip to content

Commit 7814259

Browse files
committed
Fix order of destructor calls for DawgCache and TessBaseAPI
TessBaseAPI must release its cache use before DawgCache is destroyed. Signed-off-by: Stefan Weil <[email protected]>
1 parent f37f858 commit 7814259

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

api/tesseractmain.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "allheaders.h"
2828
#include "baseapi.h"
2929
#include "basedir.h"
30+
#include "dict.h"
3031
#include "openclwrapper.h"
3132
#include "osdetect.h"
3233
#include "renderer.h"
@@ -425,6 +426,11 @@ int main(int argc, char** argv) {
425426

426427
PERF_COUNT_START("Tesseract:main")
427428

429+
// Call GlobalDawgCache here to create the global DawgCache object before
430+
// the TessBaseAPI object. This fixes the order of destructor calls:
431+
// first TessBaseAPI must be destructed, DawgCache must be the last object.
432+
tesseract::Dict::GlobalDawgCache();
433+
428434
// Avoid memory leak caused by auto variable when exit() is called.
429435
static tesseract::TessBaseAPI api;
430436

0 commit comments

Comments
 (0)