Skip to content

Commit

Permalink
Ignore illegal TESSDATA_PREFIX (not existing filesystem entry, issue #…
Browse files Browse the repository at this point in the history
…4277)

Don't check for a directory, because a symbolic link is also allowed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 3, 2024
1 parent 2991d36 commit bc490ea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ccutil/ccutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include "ccutil.h"

#include <cstdlib>
#include <cstring> // for std::strrchr
#include <cstring> // for std::strrchrA
#include <filesystem> // for std::filesystem

namespace tesseract {

Expand Down Expand Up @@ -48,6 +49,12 @@ void CCUtil::main_setup(const std::string &argv0, const std::string &basename) {

const char *tessdata_prefix = getenv("TESSDATA_PREFIX");

// Ignore TESSDATA_PREFIX if there is no matching filesystem entry.
if (tessdata_prefix != nullptr && !std::filesystem::exists(tessdata_prefix)) {
tprintf("Warning: TESSDATA_PREFIX %s does not exist, ignore it\n", tessdata_prefix);
tessdata_prefix = nullptr;
}

if (!argv0.empty()) {
/* Use tessdata prefix from the command line. */
datadir = argv0;
Expand Down

0 comments on commit bc490ea

Please sign in to comment.