Browse Source

Fix memory leak after use XGetAtomName

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/2/head
Slávek Banko 3 years ago
parent
commit
ba2fe63167
3 changed files with 23 additions and 12 deletions
  1. +11
    -10
      kxkb/kcmmisc.cpp
  2. +6
    -1
      tdekbdledsync/main.cpp
  3. +6
    -1
      tdm/kfrontend/tdm_greet.c

+ 11
- 10
kxkb/kcmmisc.cpp View File

@@ -274,26 +274,27 @@ int xkb_init()
&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
&xkb_lmaj, &xkb_lmin );
}
unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name )
{
{
int i;
if( !xkb || !xkb->names )
return 0;
for( i = 0;
i < XkbNumVirtualMods;
i++ )
{
for( i = 0; i < XkbNumVirtualMods; i++ ) {
char* modStr = XGetAtomName( xkb->dpy, xkb->names->vmods[i] );
if( modStr != NULL && strcmp(name, modStr) == 0 )
{
if( modStr == NULL ) {
continue;
}
if( strcmp(name, modStr) == 0 ) {
unsigned int mask;
XkbVirtualModsToReal( xkb, 1 << i, &mask );
XFree(modStr);
return mask;
}
}
return 0;
XFree(modStr);
}
return 0;
}

unsigned int xkb_numlock_mask()
{


+ 6
- 1
tdekbdledsync/main.cpp View File

@@ -193,11 +193,16 @@ unsigned int xkb_mask_modifier(XkbDescPtr xkb, const char *name) {
}
for( i = 0; i < XkbNumVirtualMods; i++ ) {
char* modStr = XGetAtomName( xkb->dpy, xkb->names->vmods[i] );
if( modStr != NULL && strcmp(name, modStr) == 0 ) {
if( modStr == NULL ) {
continue;
}
if( strcmp(name, modStr) == 0 ) {
unsigned int mask;
XkbVirtualModsToReal( xkb, 1 << i, &mask );
XFree(modStr);
return mask;
}
XFree(modStr);
}
return 0;
}


+ 6
- 1
tdm/kfrontend/tdm_greet.c View File

@@ -568,11 +568,16 @@ xkb_modifier_mask_work( XkbDescPtr xkb, const char *name )
return 0;
for (i = 0; i < XkbNumVirtualMods; i++) {
char *modStr = XGetAtomName( xkb->dpy, xkb->names->vmods[i] );
if (modStr != NULL && strcmp( name, modStr ) == 0) {
if( modStr == NULL ) {
continue;
}
if( strcmp( name, modStr ) == 0 ) {
unsigned int mask;
XkbVirtualModsToReal( xkb, 1 << i, &mask );
XFree(modStr);
return mask;
}
XFree(modStr);
}
return 0;
}


Loading…
Cancel
Save