changeset 397:077cdba5d5f6

FIXME cleanup.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 11 Jul 2002 05:02:14 +0000
parents 8cff79634bc5
children ee0273179c79
files decoders/mikmod.c
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);