mirror of
https://code.videolan.org/videolan/vlc
synced 2024-10-03 01:31:53 +02:00
xcb: fix some memory leaks
According to xcb docs, we are responsible for freeing this memory. Signed-off-by: Rafaël Carré <funman@videolan.org>
This commit is contained in:
parent
7d7890ed11
commit
06005e87c7
@ -181,10 +181,17 @@ static unsigned GetModifier( xcb_connection_t *p_connection, xcb_key_symbols_t *
|
||||
if( sym == 0 )
|
||||
return 0; /* no modifier */
|
||||
|
||||
const xcb_keycode_t *p_keys = xcb_key_symbols_get_keycode( p_symbols, sym );
|
||||
if( !p_keys )
|
||||
xcb_get_modifier_mapping_cookie_t r =
|
||||
xcb_get_modifier_mapping( p_connection );
|
||||
xcb_get_modifier_mapping_reply_t *p_map =
|
||||
xcb_get_modifier_mapping_reply( p_connection, r, NULL );
|
||||
if( !p_map )
|
||||
return 0;
|
||||
|
||||
xcb_keycode_t *p_keys = xcb_key_symbols_get_keycode( p_symbols, sym );
|
||||
if( !p_keys )
|
||||
goto end;
|
||||
|
||||
int i = 0;
|
||||
bool no_modifier = true;
|
||||
while( p_keys[i] != XCB_NO_SYMBOL )
|
||||
@ -198,28 +205,24 @@ static unsigned GetModifier( xcb_connection_t *p_connection, xcb_key_symbols_t *
|
||||
}
|
||||
|
||||
if( no_modifier )
|
||||
return 0;
|
||||
|
||||
xcb_get_modifier_mapping_cookie_t r =
|
||||
xcb_get_modifier_mapping( p_connection );
|
||||
xcb_get_modifier_mapping_reply_t *p_map =
|
||||
xcb_get_modifier_mapping_reply( p_connection, r, NULL );
|
||||
if( !p_map )
|
||||
return 0;
|
||||
goto end;
|
||||
|
||||
xcb_keycode_t *p_keycode = xcb_get_modifier_mapping_keycodes( p_map );
|
||||
if( !p_keycode )
|
||||
return 0;
|
||||
goto end;
|
||||
|
||||
for( int i = 0; i < 8; i++ )
|
||||
for( int j = 0; j < p_map->keycodes_per_modifier; j++ )
|
||||
for( int k = 0; p_keys[k] != XCB_NO_SYMBOL; k++ )
|
||||
if( p_keycode[i*p_map->keycodes_per_modifier + j] == p_keys[k])
|
||||
{
|
||||
free( p_keys );
|
||||
free( p_map );
|
||||
return pi_mask[i];
|
||||
}
|
||||
|
||||
end:
|
||||
free( p_keys );
|
||||
free( p_map ); // FIXME to check
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user