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

michael subversion at mplayerhq.hu
Thu Jul 16 18:35:33 CEST 2015


Author: michael
Date: Thu Jul 16 18:35:33 2015
New Revision: 37427

Log:
libvo/vo_png: Fix AVFrame creation.

The previous code used uninitialized memory and could randomly crash

Reviewed-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

Modified:
   trunk/libvo/vo_png.c

Modified: trunk/libvo/vo_png.c
==============================================================================
--- trunk/libvo/vo_png.c	Mon Jul 13 15:05:08 2015	(r37426)
+++ trunk/libvo/vo_png.c	Thu Jul 16 18:35:33 2015	(r37427)
@@ -147,7 +147,7 @@ config(uint32_t width, uint32_t height,
 
 
 static uint32_t draw_image(mp_image_t* mpi){
-    AVFrame pic;
+    AVFrame *pic;
     int buffersize;
     int res, got_pkt;
     char buf[100];
@@ -164,10 +164,11 @@ static uint32_t draw_image(mp_image_t* m
         return 1;
     }
 
+    pic = av_frame_alloc();
     avctx->width = mpi->w;
     avctx->height = mpi->h;
-    pic.data[0] = mpi->planes[0];
-    pic.linesize[0] = mpi->stride[0];
+    pic->data[0] = mpi->planes[0];
+    pic->linesize[0] = mpi->stride[0];
     buffersize = mpi->w * mpi->h * 8;
     if (outbuffer_size < buffersize) {
         av_freep(&outbuffer);
@@ -177,7 +178,8 @@ static uint32_t draw_image(mp_image_t* m
     av_init_packet(&pkt);
     pkt.data = outbuffer;
     pkt.size = outbuffer_size;
-    res = avcodec_encode_video2(avctx, &pkt, &pic, &got_pkt);
+    res = avcodec_encode_video2(avctx, &pkt, pic, &got_pkt);
+    av_frame_free(&pic);
 
     if (res < 0 || !got_pkt) {
  	    mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_PNG_ErrorInCreatePng);


More information about the MPlayer-cvslog mailing list