diff utils.c @ 32:cd0155c9022e libavformat

zero sized malloc patch by Roman Shaposhnick
author bellard
date Thu, 23 Jan 2003 22:00:57 +0000
parents 90fd30dd68b3
children fb671d87824e
line wrap: on
line diff
--- a/utils.c	Thu Jan 23 18:44:26 2003 +0000
+++ b/utils.c	Thu Jan 23 22:00:57 2003 +0000
@@ -386,11 +386,14 @@
     }
     
     /* 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 @@
 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)