summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2017-03-25 17:33:22 +0100
committerSlávek Banko <slavek.banko@axis.cz>2017-03-25 17:38:41 +0100
commit790f681ae22c49ca313f4238a2c6c807a838f4fa (patch)
treefe6160ed704ad71e879a62afb9cbdbabccbdb0b8
parent015f35e5f2b63efecba482397a754be3515d4bce (diff)
downloadtdebase-790f681ae22c49ca313f4238a2c6c807a838f4fa.tar.gz
tdebase-790f681ae22c49ca313f4238a2c6c807a838f4fa.zip
Fix memory leak after use XGetAtomName
Signed-off-by: Slávek Banko <slavek.banko@axis.cz> (cherry picked from commit ba2fe631679775cc5e25fe0e7b9769e7bc0e0f68)
-rw-r--r--kxkb/kcmmisc.cpp21
-rw-r--r--tdekbdledsync/main.cpp7
-rw-r--r--tdm/kfrontend/tdm_greet.c7
3 files changed, 23 insertions, 12 deletions
diff --git a/kxkb/kcmmisc.cpp b/kxkb/kcmmisc.cpp
index 1687b1c81..358d10450 100644
--- a/kxkb/kcmmisc.cpp
+++ b/kxkb/kcmmisc.cpp
@@ -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()
{
diff --git a/tdekbdledsync/main.cpp b/tdekbdledsync/main.cpp
index 42bb6c9df..0f4075694 100644
--- a/tdekbdledsync/main.cpp
+++ b/tdekbdledsync/main.cpp
@@ -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;
}
diff --git a/tdm/kfrontend/tdm_greet.c b/tdm/kfrontend/tdm_greet.c
index 5c77fadf0..6f8c84caf 100644
--- a/tdm/kfrontend/tdm_greet.c
+++ b/tdm/kfrontend/tdm_greet.c
@@ -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;
}