Fix RawRidFile fdopen assert crash

Rather than assert it might be better to handle fdopen()
calls that fail with more grace.  Especially since the
file wasn't being closed.

Ugh.
This commit is contained in:
Mark Liversedge
2013-05-18 11:14:20 +01:00
parent 9c3ba8fd5c
commit fdabbf632a

View File

@@ -215,9 +215,19 @@ RideFile *RawFileReader::openRideFile(QFile &file, QStringList &errors, QList<Ri
return NULL;
}
FILE *f = fdopen(file.handle(), "r");
assert(f);
// failed to associate a stream!
if (f==NULL) {
file.close();
delete rideFile;
return NULL;
}
ReadState state(rideFile, errors);
pt_read_raw(f, &state, config_cb, time_cb, data_cb, error_cb);
fclose(f);
file.close();
return rideFile;
}