[Toolserver-announce] feof(): Use with care
River Tarnell
river.tarnell at wikimedia.de
Thu May 20 00:28:08 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I've just found two PHP scripts that contain code like this:
$x = fopen(...);
while (!feof($x)) {
...
}
This is unfortunate, because it creates an infinite loop when fopen
fails: since $x is not a file handle, feof() will never return true, and
the loop will never end.
This is particularly serious with PHP because the infinite loop creates
a log message every time, which fills the system disk, but it's
something to be avoided in any language.
Error handling is not just a nicety. Doing it wrong creates serious
bugs. Do it right.
- river.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (HP-UX)
iEYEARECAAYFAkv0ghgACgkQIXd7fCuc5vLhUQCfbEzTLZQtNgOHEVf2k1aOqWkK
IyoAn07rhNNnHIGvIhTGsZyiogksMlow
=Ot4F
-----END PGP SIGNATURE-----
More information about the Toolserver-announce
mailing list