[vlc-commits] globalhotkeys/xcb: fix leak on error

Rémi Denis-Courmont git at videolan.org
Thu Dec 22 21:07:23 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Dec 22 22:04:00 2016 +0200| [23d17364b6bab8a60614623bd9f30c780d96348b] | committer: Rémi Denis-Courmont

globalhotkeys/xcb: fix leak on error

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

 modules/control/globalhotkeys/xcb.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/control/globalhotkeys/xcb.c b/modules/control/globalhotkeys/xcb.c
index 5a3f298..42fb9f4 100644
--- a/modules/control/globalhotkeys/xcb.c
+++ b/modules/control/globalhotkeys/xcb.c
@@ -325,15 +325,16 @@ static bool Mapping( intf_thread_t *p_intf )
             if( i != 0 && i_ignored == 0)
                 continue;
 
-            hotkey_mapping_t *p_map_old = p_sys->p_map;
-            p_sys->p_map = realloc( p_sys->p_map,
-                    sizeof(*p_sys->p_map) * (p_sys->i_map+1) );
-            if( !p_sys->p_map )
+            hotkey_mapping_t *p_map = realloc( p_sys->p_map,
+                              sizeof(*p_sys->p_map) * (p_sys->i_map+1) );
+            if( !p_map )
             {
-                p_sys->p_map = p_map_old;
+                free( p_keys );
                 break;
             }
-            hotkey_mapping_t *p_map = &p_sys->p_map[p_sys->i_map++];
+            p_sys->p_map = p_map;
+            p_map += p_sys->i_map;
+            p_sys->i_map++;
 
             p_map->p_keys = p_keys;
             p_map->i_modifier = i_modifier|i_ignored;



More information about the vlc-commits mailing list