File tree 1 file changed +10
-16
lines changed
1 file changed +10
-16
lines changed Original file line number Diff line number Diff line change 1
1
#include " baseapi.h"
2
2
#include " leptonica/allheaders.h"
3
3
4
- #include < libgen.h>
5
- #include < stddef.h>
6
- #include < stdint.h>
7
- #include < stdlib.h>
8
- #include < string.h>
9
- #include < string>
4
+ #include < libgen.h> // for dirname
5
+ #include < cstdio> // for printf
6
+ #include < cstdlib> // for std::getenv, std::setenv
7
+ #include < string> // for std::string
10
8
11
9
class BitReader {
12
10
private:
@@ -36,21 +34,17 @@ class BitReader {
36
34
}
37
35
};
38
36
39
- tesseract::TessBaseAPI* api = nullptr ;
37
+ static tesseract::TessBaseAPI* api = nullptr ;
40
38
41
- extern " C" int LLVMFuzzerInitialize (int * argc, char *** argv) {
42
- (void )argc;
43
- (void )argv;
44
-
45
- {
46
- char * binary_path = strdup (*argv[0 ]);
47
- const std::string filepath = dirname (binary_path);
48
- free (binary_path);
39
+ extern " C" int LLVMFuzzerInitialize (int * /* pArgc*/ , char *** pArgv) {
40
+ if (std::getenv (" TESSDATA_PREFIX" ) == nullptr ) {
41
+ std::string binary_path = *pArgv[0 ];
42
+ const std::string filepath = dirname (&binary_path[0 ]);
49
43
50
44
const std::string tessdata_path = filepath + " /" + " tessdata" ;
51
45
if (setenv (" TESSDATA_PREFIX" , tessdata_path.c_str (), 1 ) != 0 ) {
52
46
printf (" Setenv failed\n " );
53
- abort ();
47
+ std:: abort ();
54
48
}
55
49
}
56
50
You can’t perform that action at this time.
0 commit comments