mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-12 07:29:07 +08:00
Reserve extra byte in LoadDataFromFile() in case caller wants to append '\0'
This commit is contained in:
parent
83ae900549
commit
805fb7699d
@ -375,6 +375,8 @@ inline bool LoadDataFromFile(const char* filename, GenericVector<char>* data) {
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
// Trying to open a directory on Linux sets size to LONG_MAX. Catch it here.
|
||||
if (size > 0 && size < LONG_MAX) {
|
||||
// reserve an extra byte in case caller wants to append a '\0' character
|
||||
data->reserve(size + 1);
|
||||
data->resize_no_init(size);
|
||||
result = static_cast<long>(fread(&(*data)[0], 1, size, fp)) == size;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user