# HG changeset patch # User Ryan C. Gordon # Date 1026363734 0 # Node ID 077cdba5d5f61293359b3412204b9379de94552f # Parent 8cff79634bc5cc1dadff7f6f686b7149371d42b9 FIXME cleanup. diff -r 8cff79634bc5 -r 077cdba5d5f6 decoders/mikmod.c --- a/decoders/mikmod.c Thu Jul 11 04:56:36 2002 +0000 +++ b/decoders/mikmod.c Thu Jul 11 05:02:14 2002 +0000 @@ -166,6 +166,7 @@ MRWOPSREADER *reader = (MRWOPSREADER *) malloc(sizeof (MRWOPSREADER)); if (reader != NULL) { + int failed_seek = 1; int here; reader->core.Eof = _mm_RWopsReader_eof; reader->core.Read = _mm_RWopsReader_read; @@ -177,9 +178,22 @@ /* RWops does not explicitly support an eof check, so we shall find the end manually - this requires seek support for the RWop */ here = SDL_RWtell(internal->rw); - reader->end = SDL_RWseek(internal->rw, 0, SEEK_END); - SDL_RWseek(internal->rw, here, SEEK_SET); /* Move back */ - /* !!! FIXME: What happens if the seek fails? */ + if (here != -1) + { + reader->end = SDL_RWseek(internal->rw, 0, SEEK_END); + if (reader->end != -1) + { + /* Move back */ + if (SDL_RWseek(internal->rw, here, SEEK_SET) != -1) + failed_seek = 0; + } /* if */ + } /* if */ + + if (failed_seek) + { + free(reader); + reader = NULL; + } /* if */ } /* if */ return((MREADER *) reader);