[vlc-commits] omx: fix memory leak on error

Rémi Denis-Courmont git at videolan.org
Sun Jul 14 17:47:02 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 14 18:06:36 2013 +0300| [e1ee8b067472560cce1ec7a31a1f2a367747bc44] | committer: Rémi Denis-Courmont

omx: fix memory leak on error

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e1ee8b067472560cce1ec7a31a1f2a367747bc44
---

 modules/codec/omxil/vout.c |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/codec/omxil/vout.c b/modules/codec/omxil/vout.c
index 423d854..48aa744 100644
--- a/modules/codec/omxil/vout.c
+++ b/modules/codec/omxil/vout.c
@@ -289,16 +289,19 @@ static int Open(vlc_object_t *p_this)
     if (!pictures)
         goto error;
     for (unsigned int i = 0; i < p_sys->port.i_buffers; i++) {
-        picture_resource_t resource = { 0 };
-        picture_resource_t *rsc = &resource;
-        rsc->p_sys = malloc(sizeof(*rsc->p_sys));
-        if (!rsc->p_sys)
+        picture_sys_t *picsys = malloc(sizeof(*picsys));
+        if (unlikely(picsys == NULL))
             goto error;
-        rsc->p_sys->sys = p_sys;
+        picsys->sys = p_sys;
 
-        picture_t *picture = picture_NewFromResource(&fmt, rsc);
-        if (!picture)
+        picture_resource_t resource = { .p_sys = picsys };
+
+        picture_t *picture = picture_NewFromResource(&fmt, &resource);
+        if (unlikely(picture == NULL))
+        {
+            free(picsys);
             goto error;
+        }
         pictures[i] = picture;
     }
 



More information about the vlc-commits mailing list