Fix NULL flush() in PHYSFS_Io crash
authorWilli Schinmeyer <willi@schinmeyer.de>
Sun, 20 Jul 2014 13:36:56 +0200
changeset 1347 93b2026e4964
parent 1345 29ab417d9453
child 1350 b0fa354873f2
Fix NULL flush() in PHYSFS_Io crash
src/physfs.c
--- a/src/physfs.c	Fri Feb 07 16:23:12 2014 -0500
+++ b/src/physfs.c	Sun Jul 20 13:36:56 2014 +0200
@@ -1187,7 +1187,7 @@
         PHYSFS_Io *io = i->io;
         next = i->next;
 
-        if (!io->flush(io))
+        if (io->flush && !io->flush(io))
         {
             *list = i;
             return 0;
@@ -2803,7 +2803,7 @@
     rc = io->write(io, fh->buffer + fh->bufpos, fh->buffill - fh->bufpos);
     BAIL_IF_MACRO(rc <= 0, ERRPASS, 0);
     fh->bufpos = fh->buffill = 0;
-    return io->flush(io);
+    return io->flush ? io->flush(io) : 1;
 } /* PHYSFS_flush */