[FFmpeg-devel] [PATCH] Port MPlayer fixes for coverity issues in libmpcodecs.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Oct 26 21:14:05 CEST 2012


Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavfilter/libmpcodecs/vf_divtc.c        |    2 +-
 libavfilter/libmpcodecs/vf_down3dright.c  |    2 +-
 libavfilter/libmpcodecs/vf_ilpack.c       |    1 +
 libavfilter/libmpcodecs/vf_phase.c        |    2 ++
 libavfilter/libmpcodecs/vf_softpulldown.c |    3 +--
 libavfilter/libmpcodecs/vf_telecine.c     |    1 +
 libavfilter/libmpcodecs/vf_tinterlace.c   |    6 +++---
 7 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/libavfilter/libmpcodecs/vf_divtc.c b/libavfilter/libmpcodecs/vf_divtc.c
index 4c171d1..32064a5 100644
--- a/libavfilter/libmpcodecs/vf_divtc.c
+++ b/libavfilter/libmpcodecs/vf_divtc.c
@@ -413,7 +413,7 @@ static int analyze(struct vf_priv_s *p)
       n++;
       }
 
-   if(!n)
+   if(n <= 15)
       {
       mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: Empty 2-pass log file.\n",
              vf_info_divtc.name);
diff --git a/libavfilter/libmpcodecs/vf_down3dright.c b/libavfilter/libmpcodecs/vf_down3dright.c
index 4dba19a..f1e1f49 100644
--- a/libavfilter/libmpcodecs/vf_down3dright.c
+++ b/libavfilter/libmpcodecs/vf_down3dright.c
@@ -103,7 +103,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
         // hope we'll get DR buffer:
         dmpi=vf_get_image(vf->next, IMGFMT_YV12,
                           MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
-                          (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0,
+                          ((vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0),
                           mpi->w * vf->priv->scalew,
                           mpi->h / vf->priv->scaleh - vf->priv->skipline);
 
diff --git a/libavfilter/libmpcodecs/vf_ilpack.c b/libavfilter/libmpcodecs/vf_ilpack.c
index db4a849..e98d70d 100644
--- a/libavfilter/libmpcodecs/vf_ilpack.c
+++ b/libavfilter/libmpcodecs/vf_ilpack.c
@@ -437,6 +437,7 @@ static int vf_open(vf_instance_t *vf, char *args)
         mp_msg(MSGT_VFILTER, MSGL_WARN,
             "ilpack: unknown mode %d (fallback to linear)\n",
             vf->priv->mode);
+        /* Fallthrough */
     case 1:
         vf->priv->pack[0] = pack_li_0;
         vf->priv->pack[1] = pack_li_1;
diff --git a/libavfilter/libmpcodecs/vf_phase.c b/libavfilter/libmpcodecs/vf_phase.c
index 7dd642e..101290d 100644
--- a/libavfilter/libmpcodecs/vf_phase.c
+++ b/libavfilter/libmpcodecs/vf_phase.c
@@ -242,6 +242,8 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
 
 static void uninit(struct vf_instance *vf)
    {
+   if (!vf->priv)
+       return;
    free(vf->priv->buf[0]);
    free(vf->priv->buf[1]);
    free(vf->priv->buf[2]);
diff --git a/libavfilter/libmpcodecs/vf_softpulldown.c b/libavfilter/libmpcodecs/vf_softpulldown.c
index 04d1eae..1a66e56 100644
--- a/libavfilter/libmpcodecs/vf_softpulldown.c
+++ b/libavfilter/libmpcodecs/vf_softpulldown.c
@@ -144,12 +144,11 @@ static void uninit(struct vf_instance *vf)
 
 static int vf_open(vf_instance_t *vf, char *args)
 {
-    struct vf_priv_s *p;
     vf->config = config;
     vf->put_image = put_image;
     vf->uninit = uninit;
     vf->default_reqs = VFCAP_ACCEPT_STRIDE;
-    vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
+    vf->priv = calloc(1, sizeof(struct vf_priv_s));
     vf->priv->state = 0;
     return 1;
 }
diff --git a/libavfilter/libmpcodecs/vf_telecine.c b/libavfilter/libmpcodecs/vf_telecine.c
index 3b92518..e5f934e 100644
--- a/libavfilter/libmpcodecs/vf_telecine.c
+++ b/libavfilter/libmpcodecs/vf_telecine.c
@@ -62,6 +62,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
                 dmpi->stride[2]*2, mpi->stride[2]*2);
         }
         ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
+        /* Fallthrough */
     case 1:
     case 2:
         memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h,
diff --git a/libavfilter/libmpcodecs/vf_tinterlace.c b/libavfilter/libmpcodecs/vf_tinterlace.c
index 6dbcbc9..8cd6ac8 100644
--- a/libavfilter/libmpcodecs/vf_tinterlace.c
+++ b/libavfilter/libmpcodecs/vf_tinterlace.c
@@ -218,10 +218,10 @@ static int vf_open(vf_instance_t *vf, char *args)
     vf->uninit = uninit;
     vf->default_reqs = VFCAP_ACCEPT_STRIDE;
     vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
-    vf->priv->mode = 0;
+    p->mode = 0;
     if (args)
-      sscanf(args, "%d", &vf->priv->mode);
-    vf->priv->frame = 0;
+      sscanf(args, "%d", &p->mode);
+    p->frame = 0;
     return 1;
 }
 
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list