Skip to content

Fix fread call when file size is zero

Compare
Choose a tag to compare
@janmartenjongerius janmartenjongerius released this 10 Jul 09:30
· 94 commits to master since this release
e5e6eeb

When the file size is zero, the call to SplFileObject::fread fails,
because it only accepts a size greater than zero.
This has been fixed by testing the size and optionally falling back to
an empty string.

The unit test has been expanded to prevent regression.

Thanks to @chekalskiy for reporting the bug
Thanks to @willemstuursma for offering an alternate fix