[Libav-user] (AVStream *)av_malloc(sizeof(AVStream)) crashed the application

Wenpeng Zhou zhou.wenpeng at rdnet.fi
Tue Oct 30 12:18:54 CET 2012


Hi Chandranath

 

Thanks!

 

But I already allocated memory for the pointer *ic_enc_mjpeg

 

AVFormatContext *ic_enc_mjpeg;

ic_enc_mjpeg = (AVFormatContext *)av_malloc(sizeof(AVFormatContext));

 

Then I tried to allocate the memory for ic_enc_mjpeg->streams[0], then it
crashed.

 

From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org]
On Behalf Of Chandranath Bhattacharyya
Sent: 30. lokakuuta 2012 13:12
To: This list is about using libavcodec, libavformat, libavutil, libavdevice
and libavfilter.
Subject: Re: [Libav-user] (AVStream *)av_malloc(sizeof(AVStream)) crashed
the application

 

> AVFormatContext *ic_enc_mjpeg;

> ic_enc_mjpeg = (AVFormatContext *)av_malloc(sizeof(AVFormatContext));

> ic_enc_mjpeg->streams[0] = (AVStream *)av_malloc(sizeof(AVStream));

 

> But 

> ic_enc_mjpeg->streams[0] = (AVStream *)av_malloc(sizeof(AVStream));

> crashed the application.

 

 

AVFormatContext *ic_enc_mjpeg; //è Here ic_enc_mjpeg is uninitialized.

ic_enc_mjpeg->streams[0] = (AVStream *)av_malloc(sizeof(AVStream));

=> ic_enc_mjpeg->stream[0] accesses uninitialized pointer ic_enc_mjpeg
causing crash.

 

Situation is same as the following:

struct A {

    int a;

};

A *pa;

pA->a = 1; // crash

 

Regards,

Chandranath

 

From: libav-user-bounces at ffmpeg.org [mailto:libav-user-bounces at ffmpeg.org]
On Behalf Of Wenpeng Zhou
Sent: 30 October 2012 16:35
To: 'This list is about using libavcodec, libavformat, libavutil,
libavdevice and libavfilter.'
Subject: [Libav-user] (AVStream *)av_malloc(sizeof(AVStream)) crashed the
application

 

Hi, 

I use 

 

AVFormatContext *ic_enc_mjpeg;

ic_enc_mjpeg = (AVFormatContext *)av_malloc(sizeof(AVFormatContext));

ic_enc_mjpeg->streams[0] = (AVStream *)av_malloc(sizeof(AVStream));

 

But 

ic_enc_mjpeg->streams[0] = (AVStream *)av_malloc(sizeof(AVStream));

crashed the application.

 

I use VC++ 2010. 

 

What is the reason?

 

Thanks!

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121030/5d2ed7ee/attachment.html>


More information about the Libav-user mailing list