* Dereference pointer after NULL check (CID 1385638)
Move the statement which dereferences the pointer variable "current"
after the NULL check.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Dereference pointer after NULL check (CID 1385635)
Move the statement which dereferences the pointer variable "current"
after the NULL check.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Dereference pointer after NULL check (CID 1385634)
Move the statement which dereferences the pointer variable "current"
after the NULL check.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
* Fix CID 1164527 'Constant' variable guards dead code
Signed-off-by: Stefan Weil <sw@weilnetz.de>
ftell returns a long value which can be negative when an error occurred.
It returns LONG_MAX for directories.
Both cases were not handled by the old code.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This fixes these compiler warnings:
ccmain/equationdetect.cpp:1519:2: warning: extra ‘;’ [-Wpedantic]
ccstruct/blobs.cpp:65:17: warning: extra ‘;’ [-Wpedantic]
ccstruct/blobs.h:178:18: warning: extra ‘;’ [-Wpedantic]
ccstruct/ratngs.cpp:36:22: warning: extra ‘;’ [-Wpedantic]
ccstruct/ratngs.cpp:37:22: warning: extra ‘;’ [-Wpedantic]
ccutil/ambigs.cpp:46:20: warning: extra ‘;’ [-Wpedantic]
ccutil/ambigs.h:137:21: warning: extra ‘;’ [-Wpedantic]
cutil/structures.cpp:36:45: warning: extra ‘;’ [-Wpedantic]
textord/equationdetectbase.cpp:65:2: warning: extra ‘;’ [-Wpedantic]
textord/equationdetectbase.h:57:2: warning: extra ‘;’ [-Wpedantic]
wordrec/lm_state.cpp:25:28: warning: extra ‘;’ [-Wpedantic]
wordrec/lm_state.h:190:29: warning: extra ‘;’ [-Wpedantic]
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Compiler warning:
ccutil/unicharcompress.cpp:76:76: warning: format ‘%x’ expects argument of type ‘unsigned int*’, but argument 3 has type ‘int*’ [-Wformat=]
ccutil/unicharcompress.cpp:80:31: warning: format ‘%x’ expects argument of type ‘unsigned int*’, but argument 3 has type ‘int*’ [-Wformat=]
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Replacing inttypes.h by cinttypes fixes a problem with glibc < 2.18:
In older inttypes.h, the standard C format macros are only defined for
C++ when the macro __STDC_FORMAT_MACROS is set.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Several code locations call that method with a normal C string,
so overload it to accept that without a conversion to a STRING
object. This saves unneeded new / memcpy / delete operations.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Tesseract crashes with an unhandled exception (std::bad_alloc) if it gets
a bad tessdata file where the numEntries data field is very large (also
after swapping), for example 0x77777777.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
It's not necessary to initialize the vector with 0,
because the initial values are read from file.
Fix also an assertion when trying to read an empty file.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
There exist standard macro definitions for the printf format specifiers.
MS Visual Studio does not support that standard (at least not in older
versions), so local definitions are needed there.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Both functions simply call malloc, free.
Remove also unneeded null pointer checks and use calloc where possible.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This fixes a compiler warning:
ccutil/scanutils.cpp:284:7: warning:
variable 'sign' set but not used [-Wunused-but-set-variable]
Signed-off-by: Stefan Weil <sw@weilnetz.de>