[MPlayer-cvslog] r36424 - trunk/libvo/vo_png.c

al subversion at mplayerhq.hu
Wed Aug 14 12:21:30 CEST 2013


Author: al
Date: Wed Aug 14 12:21:30 2013
New Revision: 36424

Log:
vo png: Error handling and clean up

Simplify error path; returning 1 is obfuscated and not different
from returning VO_TRUE. We do not want to fatally error out anyway,
so printing a warning should be enough and not different from the
current behaviour.

Use av_free_packet, it is the counter part for av_init_packet .
It could e.g. potentially free side data. The buffer itself
will not be freed as is intended for our custom buffer which
we will try to re-use.

Modified:
   trunk/libvo/vo_png.c

Modified: trunk/libvo/vo_png.c
==============================================================================
--- trunk/libvo/vo_png.c	Wed Aug 14 12:16:46 2013	(r36423)
+++ trunk/libvo/vo_png.c	Wed Aug 14 12:21:30 2013	(r36424)
@@ -176,14 +176,14 @@ static uint32_t draw_image(mp_image_t* m
     pkt.size = outbuffer_size;
     res = avcodec_encode_video2(avctx, &pkt, &pic, &got_pkt);
 
-    if(res < 0){
+    if (res < 0 || !got_pkt) {
  	    mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng);
-            fclose(outfile);
-	    return 1;
+    } else {
+        fwrite(outbuffer, pkt.size, 1, outfile);
     }
 
-    fwrite(outbuffer, pkt.size, 1, outfile);
     fclose(outfile);
+    av_free_packet(&pkt);
 
     return VO_TRUE;
 }


More information about the MPlayer-cvslog mailing list