Commit Graph

2965 Commits

Author SHA1 Message Date
Stefan Weil
c1da5fbac4 Fix CID 1164704 (Untrusted value as argument)
Limit the matrix to UINT16_MAX x UINT16_MAX.

Larger dimensions could also result in an arithmetic overflow
when multiplying the two dimensions.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-06 16:11:29 +02:00
Stefan Weil
8871f4d622 Fix CID 1164686 (Use of untrusted scalar value)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-06 16:11:29 +02:00
Stefan Weil
92e2ad0471 Fix CID 1164703 (Untrusted value as argument)
Wrong file data could give a large value for the number of vector elements
resulting in very large memory allocations.

Limit the allowed data range to UINT16_MAX (65535) elements
which hopefully should be sufficient for all use cases.

Changing the data type of the related member variables from int to
uint32_t allowed removing several type casts.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-06 16:11:10 +02:00
Egor Pugin
a078ce02bb
Merge pull request #1756 from stweil/cov
Fix two issues reported by Coverity Scan
2018-07-05 23:10:39 +03:00
Egor Pugin
f2f9bed41d
Merge pull request #1755 from stweil/clean
Remove unused iterator
2018-07-05 23:10:18 +03:00
Stefan Weil
bfe2a79502 Fix CID 1164566 (Dereference after null check)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 22:07:36 +02:00
Stefan Weil
036c72ca2f Fix CID 1164733 (Resource leak)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 22:07:36 +02:00
Stefan Weil
8d60a1849c Remove unused iterator
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 21:20:27 +02:00
Egor Pugin
3ea9cff149
Merge pull request #1752 from stweil/api
API fixes
2018-07-05 17:28:48 +03:00
Egor Pugin
09f4179e89
Merge pull request #1754 from stweil/fix
Fix compiler warnings [-Wmissing-prototypes]
2018-07-05 17:28:36 +03:00
Egor Pugin
023635e811
Merge pull request #1753 from stweil/break
Fix empty statements
2018-07-05 17:24:53 +03:00
Stefan Weil
d2febafdcd Fix compiler warnings [-Wmissing-prototypes]
Add missing include statements, add missing "static" qualifiers or
remove functions which are not used at all.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 16:03:02 +02:00
Stefan Weil
8ad7f049ea Fix empty statements
* Add break in default case to avoid potential problems with
  future case statements following the default case.

* Remove empty statement.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 15:17:54 +02:00
Stefan Weil
ffb501936c Fix prototype for API function TessBaseGetBlockTextOrientations
The declaration did not match the implementation (BOOL / bool).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 14:49:48 +02:00
Stefan Weil
790b410fd6 Remove unused API function TessBaseAPIDetectOS
It was not declared in capi.h, so external users could not use it anyway.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 14:49:48 +02:00
Egor Pugin
4ca452d9b7
Merge pull request #1750 from stweil/fix
Fix several compiler warnings (clang)
2018-07-05 14:43:03 +03:00
Stefan Weil
f107f116d9 Fix compiler warnings [-Wconditional-uninitialized]
clang warnings:

src/ccstruct/coutln.cpp:231:15: warning:
 variable 'destindex' may be uninitialized when used here [-Wconditional-uninitialized]
src/wordrec/language_model.cpp:1170:27: warning:
 variable 'expected_gap' may be uninitialized when used here [-Wconditional-uninitialized]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 12:07:04 +02:00
Stefan Weil
a74d467e90 Fix compiler warnings [-Wcomma]
clang warnings:

src/api/baseapi.cpp:1642:18: warning:
 possible misuse of comma operator here [-Wcomma]
src/api/baseapi.cpp:1642:31: warning:
 possible misuse of comma operator here [-Wcomma]
src/api/baseapi.cpp:1642:45: warning:
 possible misuse of comma operator here [-Wcomma]
src/api/baseapi.cpp:1652:16: warning:
 possible misuse of comma operator here [-Wcomma]
src/api/baseapi.cpp:1652:30: warning:
 possible misuse of comma operator here [-Wcomma]
src/api/baseapi.cpp:1662:17: warning:
 possible misuse of comma operator here [-Wcomma]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 12:07:04 +02:00
Stefan Weil
296a836f4e Fix compiler warnings [-Wunused-const-variable]
clang warnings:

src/classify/trainingsampleset.cpp:39:11: warning:
 unused variable 'kMinOutlierSamples' [-Wunused-const-variable]
src/lstm/lstmrecognizer.cpp:45:11: warning:
 unused variable 'kMaxChoices' [-Wunused-const-variable]
src/training/dawg2wordlist.cpp:28:11: warning:
 unused variable 'kDictDebugLevel' [-Wunused-const-variable]
src/training/stringrenderer.cpp:50:21: warning:
 unused variable 'kWordJoiner' [-Wunused-const-variable]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 12:07:04 +02:00
zdenop
d27f5b58f9
Merge pull request #1747 from stweil/fix
Fix syntax errors introduced by last commit (regression)
2018-07-05 07:54:07 +02:00
Stefan Weil
787bde5630 Fix syntax errors introduced by last commit (regression)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-05 07:34:04 +02:00
zdenop
cf6c79d842
Merge pull request #1746 from stweil/fix
Fix some warnings from clang compiler
2018-07-04 22:09:17 +02:00
Stefan Weil
d960a50c12 Fix compiler warning [-Wshadow-field-in-constructor]
clang warning:

src/ccstruct/polyblk.cpp:48:36: warning:
 constructor parameter 'box' shadows the field 'box' of 'POLY_BLOCK'
 [-Wshadow-field-in-constructor]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 21:58:33 +02:00
Stefan Weil
c1be1024be Fix compiler warning [-Wtautological-undefined-compare]
clang warning:

src/lstm/networkio.cpp:56:15: warning:
 'this' pointer cannot be null in well-defined C++ code;
 comparison may be assumed to always evaluate to true [-Wtautological-undefined-compare]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 21:58:33 +02:00
Stefan Weil
52d392da50 Fix compiler warning [-Wunused-function]
clang warning:

src/lstm/lstmrecognizer.cpp:411:13: warning:
 unused function 'NullIsBest' [-Wunused-function]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 21:58:33 +02:00
Stefan Weil
6cc35646f8 Fix compiler warning [-Wunreachable-code-break]
clang warning:

src/lstm/network.cpp:249:7:
 warning: 'break' will never be executed [-Wunreachable-code-break]

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 21:58:33 +02:00
Egor Pugin
a24d7cf868
Merge pull request #1745 from stweil/nullptr
Fix compiler warnings [-Wzero-as-null-pointer-constant]
2018-07-04 22:48:22 +03:00
Stefan Weil
bdf09f40b1 Fix compiler warnings [-Wzero-as-null-pointer-constant]
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 20:40:56 +02:00
zdenop
d1e0a4b9e3
Merge pull request #1744 from stweil/fix
Fix build with legacy engine disabled
2018-07-04 18:18:59 +02:00
Stefan Weil
60fcff5ed9 Fix build with legacy engine disabled (part 2)
The functions TessBaseAPIInitLangMod, TessBaseAPIClearAdaptiveClassifier
and TessBaseAPIDetectOrientationScript need conditional compilation.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 17:56:42 +02:00
Stefan Weil
081793ff48 Fix build with legacy engine disabled
Instead of defining the DISABLED_LEGACY_ENGINE macro in config_auto.h
(which is not included by all source files), define it as a preprocessor
option for those parts of the code which require it.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 17:56:42 +02:00
zdenop
20e53b119a
Merge pull request #1742 from stweil/casts
Remove unneeded type casts
2018-07-04 15:35:49 +02:00
Stefan Weil
c8b5a29ce9 Remove unneeded type casts
This removes unneded type casts to (char*) and (const char*).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-04 14:23:55 +02:00
zdenop
6d3b6b1f7b
Merge pull request #1740 from amitdo/disable-legacy
Add an option to compile tesseract without the code of the legacy OCR engine
2018-07-04 12:46:34 +02:00
Amit D
62c7b796da
Merge branch 'master' into disable-legacy 2018-07-04 11:14:33 +03:00
amitdo
15fb491be4 Add missing #ifdef in tesseractmain.cpp 2018-07-04 09:57:12 +03:00
amitdo
134779f758 Fix duplicate #ifndef in blobclass.cpp 2018-07-04 08:49:58 +03:00
zdenop
b502bbf58e
Merge pull request #1738 from stweil/whitespace
Replace tabs by blanks in source code
2018-07-03 18:17:07 +02:00
amitdo
aa9f4b4861 Add an option to compile tesseract without the code of the legacy OCR engine 2018-07-03 18:49:42 +03:00
Stefan Weil
6d170a15ec Replace tabs by blanks in source code
blobs.cpp had many tabs and was formatted with clang-format.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 16:29:14 +02:00
zdenop
c9efe5f509
Merge pull request #1737 from stweil/nwmain
Remove nwmain.h and fix syntax error
2018-07-03 16:12:57 +02:00
Stefan Weil
626a229cac Remove nwmain.h
The macro DECLARE_MAIN is not used by the current Tesseract code.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 15:54:41 +02:00
Stefan Weil
f8684cb0fd Fix syntax error (regression)
It was introduced in commit bb7bb1f0b8.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 15:53:42 +02:00
zdenop
4b26b8d9a9
Merge pull request #1735 from stweil/pdblock
Remove blckerr.h
2018-07-03 15:24:09 +02:00
zdenop
04e0273a59
Merge pull request #1736 from stweil/comments
Remove old comments for exceptions
2018-07-03 15:23:27 +02:00
Stefan Weil
bb7bb1f0b8 Remove old comments for exceptions
Exceptions are no longer used.

Remove also some history comments and fix several comments.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 14:53:00 +02:00
Stefan Weil
889f7eaa1b Remove blckerr.h
Move the two ERRCODE constants which are still in use to pdblock.cpp.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 14:08:57 +02:00
zdenop
b0c9d5b4f4
Merge pull request #1734 from stweil/danerror
Replace function DoError and remove danerror.cpp, danerror.h
2018-07-03 13:30:42 +02:00
Stefan Weil
872813245d Replace function DoError and remove danerror.cpp, danerror.h
This allows also removing all error trap macros.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2018-07-03 13:21:17 +02:00
zdenop
412186b396
Merge pull request #1733 from stweil/cutil
Clean up cutil.h
2018-07-03 12:51:35 +02:00