aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Shaposhnik <roman@shaposhnik.org>2003-01-23 22:00:57 +0000
committerFabrice Bellard <fabrice@bellard.org>2003-01-23 22:00:57 +0000
commit98486a6bc01288a0ac46ae8d54940a994972b90e (patch)
tree368b6b88e3c331d08da63e82a9ff129bb4ef1c27
parenta5df11ab1e0e2c4bc4218a6543f6dfaf7169d4e4 (diff)
downloadffmpeg-98486a6bc01288a0ac46ae8d54940a994972b90e.tar.gz
zero sized malloc patch by Roman Shaposhnick
Originally committed as revision 1501 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--ffserver.c9
-rw-r--r--libavformat/utils.c25
2 files changed, 22 insertions, 12 deletions
diff --git a/ffserver.c b/ffserver.c
index e003a9e0ad..9461e92c07 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2457,9 +2457,12 @@ static int http_receive_data(HTTPContext *c)
if (!fmt_in)
goto fail;
- s.priv_data = av_mallocz(fmt_in->priv_data_size);
- if (!s.priv_data)
- goto fail;
+ if (fmt_in->priv_data_size > 0) {
+ s.priv_data = av_mallocz(fmt_in->priv_data_size);
+ if (!s.priv_data)
+ goto fail;
+ } else
+ s.priv_data = NULL;
if (fmt_in->read_header(&s, 0) < 0) {
av_freep(&s.priv_data);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f811b2c628..c2e9328cd3 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -386,11 +386,14 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
}
/* allocate private data */
- ic->priv_data = av_mallocz(fmt->priv_data_size);
- if (!ic->priv_data) {
- err = AVERROR_NOMEM;
- goto fail;
- }
+ if (fmt->priv_data_size > 0) {
+ ic->priv_data = av_mallocz(fmt->priv_data_size);
+ if (!ic->priv_data) {
+ err = AVERROR_NOMEM;
+ goto fail;
+ }
+ } else
+ ic->priv_data = NULL;
/* default pts settings is MPEG like */
av_set_pts_info(ic, 33, 1, 90000);
@@ -722,10 +725,14 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
{
int ret;
-
- s->priv_data = av_mallocz(s->oformat->priv_data_size);
- if (!s->priv_data)
- return AVERROR_NOMEM;
+
+ if (s->oformat->priv_data_size > 0) {
+ s->priv_data = av_mallocz(s->oformat->priv_data_size);
+ if (!s->priv_data)
+ return AVERROR_NOMEM;
+ } else
+ s->priv_data = NULL;
+
if (s->oformat->set_parameters) {
ret = s->oformat->set_parameters(s, ap);
if (ret < 0)