I am using fread to read a large chunk of image data (> 1 MB) from a file. I recently encountered a bug on MinGW with Windows network shares where a single call to fread like
fread(file, 4, 100000, data);
fails reliably with an "Invalid argument" error, but 10 calls of
fread(file, 4, 10000, data); data += 10000;
succeed and yield the right result. I deduce there must be a maximum size for an fread, which I was not aware of before. I bisected the allowed size of fread and found it to be between 31000 and 32000 blocks of 4 bytes. Has anyone encountered this before? Is this a bug in MinGW? Is there any way to determine the maximum "safe" size for fread?
EINVAL
is not a documented error code forfread
. How are you doing your error checking? – Sabayonfile
aFILE *
? because the first argument tofread
is the buffer, not the file. – Enduring