fclose crashes
Bugzilla Link | 915 |
Created on | Feb 22, 2012 10:49 |
Resolution | FIXED |
Resolved on | Mar 01, 2012 19:01 |
Version | svn |
OS | Linux |
Architecture | PC |
Extended Description
There's a bug with fclose.c for sac2c-1.00-17729-beta-linux-i386.tar.gz It expects a two star pointer while SAC only gives it a one. Fix in stdlib/world/stdio/src/File/fclose.c: // bug in SAC: void SACfclose(FILE **stream) // fix is here below: void SACfclose(FILE *stream) { ... } Use this SAC file for testing stdio: use File: { File, fopen, fclose, fseek, ftell, rewind }; use RuntimeError: { error }; use CommandLine: { argc, argv }; use SysErr: { fail }; import ScalarArith: all; int main() { if (argc() < 2) { error(1, "Need at least one file arg"); } for (i = 1; i < argc(); ++i) { name = argv(i); err, fp = fopen( name, "r"); if (fail(err)) { if ( SysErr::fail(err) == true) { error( (:int)err, "Failed to open %s for reading", name); } } else { fseek(fp, 0, 2); size = ftell(fp); rewind(fp); fclose(fp); } } return 0; }