Merge pull request #920 from stweil/fix

Improve robustness of TessdataManager
This commit is contained in:
Egor Pugin 2017-05-14 23:38:12 +03:00 committed by GitHub
commit 2a4483da4c

View File

@ -54,6 +54,7 @@ bool TessdataManager::LoadMemBuffer(const char *name, const char *data,
swap_ = num_entries > kMaxNumTessdataEntries || num_entries < 0;
fp.set_swap(swap_);
if (swap_) ReverseN(&num_entries, sizeof(num_entries));
if (num_entries > kMaxNumTessdataEntries || num_entries < 0) return false;
GenericVector<inT64> offset_table;
offset_table.resize_no_init(num_entries);
if (fp.FReadEndian(&offset_table[0], sizeof(offset_table[0]), num_entries) !=