[MPlayer-dev-eng] [PATCH] check -dumpstream file writes

Eric Lammerts eric at lammerts.org
Mon May 19 22:37:52 CEST 2003


Hi,
When writing a file with -dumpstream, mplayer doesn't check the return
values of the fwrite()/fclose() calls. Patch below fixes this.

Eric

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.694
diff -u -r1.694 mplayer.c
--- mplayer.c	17 May 2003 09:20:58 -0000	1.694
+++ mplayer.c	19 May 2003 20:29:23 -0000
@@ -1293,9 +1293,17 @@
   }
   while(!stream->eof){
       len=stream_read(stream,buf,4096);
-      if(len>0) fwrite(buf,len,1,f);
+      if(len>0) {
+        if(fwrite(buf,len,1,f) != 1) {
+          mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, stream_dump_name);;
+          exit_player(MSGTR_Exit_error);
+        }
+      }
+  }
+  if(fclose(f)) {
+    mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, stream_dump_name);;
+    exit_player(MSGTR_Exit_error);
   }
-  fclose(f);
   mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);
   exit_player_with_rc(MSGTR_Exit_eof, 0);
 }



More information about the MPlayer-dev-eng mailing list