[vlc-commits] access: bluray: check and remove xmalloc in get_attachments

Francois Cartegnie git at videolan.org
Mon Aug 28 09:30:34 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Aug 25 13:02:14 2017 +0200| [fa26e3d61b002d886842c004bcbfd7473a7ea1be] | committer: Francois Cartegnie

access: bluray: check and remove xmalloc in get_attachments

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

 modules/access/bluray.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index 76e5bc6009..b1408e4fb6 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -1949,10 +1949,16 @@ static int blurayControl(demux_t *p_demux, int query, va_list args)
         if (p_sys->i_attachments <= 0)
             return VLC_EGENERIC;
 
-        *pi_int = p_sys->i_attachments;
-        *ppp_attach = xmalloc(sizeof(input_attachment_t *) * p_sys->i_attachments);
+        *pi_int = 0;
+        *ppp_attach = malloc(sizeof(input_attachment_t *) * p_sys->i_attachments);
+        if(!*ppp_attach)
+            return VLC_EGENERIC;
         for (int i = 0; i < p_sys->i_attachments; i++)
-            (*ppp_attach)[i] = vlc_input_attachment_Duplicate(p_sys->attachments[i]);
+        {
+            input_attachment_t *p_dup = vlc_input_attachment_Duplicate(p_sys->attachments[i]);
+            if(p_dup)
+                (*ppp_attach)[(*pi_int)++] = p_dup;
+        }
         return VLC_SUCCESS;
     }
 



More information about the vlc-commits mailing list