Skip to content

Commit 52fddc3

Browse files
committed
TFile: Relax assertion and allow FRead, FWrite with count == 0
The assertions introduced by commit 8bea6bc were too strict. The first one failed in osd_test, the second one failed in `tesseract IMAGE BASE --psm 13 lstm.train`. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 83ae900 commit 52fddc3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ccutil/serialis.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int TFile::FReadEndian(void* buffer, size_t size, int count) {
112112
int TFile::FRead(void* buffer, size_t size, int count) {
113113
ASSERT_HOST(!is_writing_);
114114
ASSERT_HOST(size > 0);
115-
ASSERT_HOST(count > 0);
115+
ASSERT_HOST(count >= 0);
116116
size_t required_size;
117117
if (SIZE_MAX / size <= count) {
118118
// Avoid integer overflow.
@@ -160,7 +160,7 @@ bool TFile::CloseWrite(const STRING& filename, FileWriter writer) {
160160
int TFile::FWrite(const void* buffer, size_t size, int count) {
161161
ASSERT_HOST(is_writing_);
162162
ASSERT_HOST(size > 0);
163-
ASSERT_HOST(count > 0);
163+
ASSERT_HOST(count >= 0);
164164
ASSERT_HOST(SIZE_MAX / size > count);
165165
size_t total = size * count;
166166
const char* buf = static_cast<const char*>(buffer);

0 commit comments

Comments
 (0)