[ scummvm-Bugs-1048129 ] Bug in File class

SourceForge.net noreply at sourceforge.net
Sat Oct 16 01:47:37 CEST 2004


Bugs item #1048129, was opened at 2004-10-16 02:47
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418820&aid=1048129&group_id=37116

Category: None
Group: All Games
Status: Open
Resolution: None
Priority: 8
Submitted By: Eugene Sandulenko (sev)
Assigned to: Max Horn (fingolfin)
Summary: Bug in File class

Initial Comment:
There is a bug in file class which prevents eof()
method from working.

As I don't understand reason for particular code line,
I post it here, though I suspect it's some kind of
copy'n'paste error.

The problem is in this chunk:

	real_len = fread(ptr2, 1, len, _handle);
	if (real_len < len) {
		clearerr(_handle); // <- clears eof status
		_ioFailed = true;
	}

line with comment on it prevents eof() from reporting.
And simple loop like this:

  File in;
  in.open("blah");
  while(!in.eof()) {
    in.read(&buf, 1);
  }

will never end.

Same thing is in write() method, which may trigger
similiar bug as well. What's the reason of clearing
error of _handle? Could that be removed? If it has to
be there, then something like this should be added:

  if (real_len < len) {
    _eof = feof(_handle) != 0;
    clearerr(_handle);
    _ioFailed = true;
  }

  and then remove that _eof in eof() method.
	

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418820&aid=1048129&group_id=37116




More information about the Scummvm-tracker mailing list