mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-17 23:44:22 +00:00
Got rid of some more ioFailed uses (also fixed a potential leak in graphics/font.cpp, and handle eos correctly in the FLAC code)
svn-id: r42488
This commit is contained in:
parent
96abaaea6d
commit
6b98c4c4e7
@ -126,7 +126,7 @@ KyraEngine_v1::kReadSaveHeaderError KyraEngine_v1::readSaveHeader(Common::Seekab
|
||||
}
|
||||
}
|
||||
|
||||
return (in->ioFailed() ? kRSHEIoError : kRSHENoError);
|
||||
return ((in->err() || in->eos()) ? kRSHEIoError : kRSHENoError);
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *KyraEngine_v1::openSaveForReading(const char *filename, SaveHeader &header) {
|
||||
|
@ -355,10 +355,10 @@ Common::Error ToucheEngine::loadGameState(int num) {
|
||||
} else {
|
||||
f->skip(2 + kGameStateDescriptionLen);
|
||||
loadGameStateData(f);
|
||||
if (!f->ioFailed()) {
|
||||
loadOk = true;
|
||||
} else {
|
||||
if (f->err() || f->eos()) {
|
||||
warning("Can't read file '%s'", gameStateFileName.c_str());
|
||||
} else {
|
||||
loadOk = true;
|
||||
}
|
||||
}
|
||||
delete f;
|
||||
|
@ -88,7 +88,7 @@ Common::Error TuckerEngine::loadGameState(int num) {
|
||||
} else {
|
||||
f->skip(2);
|
||||
saveOrLoadGameStateData(*f);
|
||||
if (f->ioFailed()) {
|
||||
if (f->err() || f->eos()) {
|
||||
warning("Can't read file '%s'", gameStateFileName.c_str());
|
||||
ret = Common::kReadingFailed;
|
||||
} else {
|
||||
|
@ -733,6 +733,14 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
|
||||
}
|
||||
}
|
||||
|
||||
if (stream.err() || stream.eos()) {
|
||||
free(data->bits);
|
||||
free(data->offset);
|
||||
free(data->width);
|
||||
free(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FontDesc desc;
|
||||
desc.name = data->name;
|
||||
desc.maxwidth = data->maxwidth;
|
||||
@ -752,8 +760,7 @@ NewFont *NewFont::loadFromCache(Common::SeekableReadStream &stream) {
|
||||
desc.bits_size = data->bits_size;
|
||||
|
||||
font = new NewFont(desc, data);
|
||||
if (!font || stream.err()) {
|
||||
delete font;
|
||||
if (!font) {
|
||||
free(data->bits);
|
||||
free(data->offset);
|
||||
free(data->width);
|
||||
|
@ -402,21 +402,23 @@ int FlacInputStream::readBuffer(int16 *buffer, const int numSamples) {
|
||||
}
|
||||
|
||||
inline ::FLAC__SeekableStreamDecoderReadStatus FlacInputStream::callbackRead(FLAC__byte buffer[], FLAC_size_t *bytes) {
|
||||
if (*bytes == 0)
|
||||
if (*bytes == 0) {
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; /* abort to avoid a deadlock */
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */
|
||||
#endif
|
||||
}
|
||||
|
||||
const uint32 bytesRead = _inStream->read(buffer, *bytes);
|
||||
|
||||
if (bytesRead == 0 && _inStream->ioFailed())
|
||||
if (bytesRead == 0) {
|
||||
#ifdef LEGACY_FLAC
|
||||
return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
||||
return _inStream->eos() ? FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK : FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
||||
#else
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
return _inStream->eos() ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
||||
#endif
|
||||
}
|
||||
|
||||
*bytes = static_cast<uint>(bytesRead);
|
||||
#ifdef LEGACY_FLAC
|
||||
|
Loading…
x
Reference in New Issue
Block a user