summaryrefslogtreecommitdiff
path: root/libmate-desktop
diff options
context:
space:
mode:
authorAlexei Sorokin <[email protected]>2017-02-02 18:52:49 +0300
committerAlexei Sorokin <[email protected]>2017-02-02 18:52:49 +0300
commit553c0eaef8b060edf49b3d3c2e432554aee5a7f2 (patch)
treec3a496f0d26064a8d559cdc18a96ee8935d94579 /libmate-desktop
parent281702431fdbb69605bdb26d60d7997adf27da67 (diff)
downloadmate-desktop-553c0eaef8b060edf49b3d3c2e432554aee5a7f2.tar.bz2
mate-desktop-553c0eaef8b060edf49b3d3c2e432554aee5a7f2.tar.xz
mate-bg: Avoid possible X11 data leaks
Diffstat (limited to 'libmate-desktop')
-rw-r--r--libmate-desktop/mate-bg.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c
index 8bd8a54..9a4f610 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -1495,7 +1495,7 @@ mate_bg_set_root_pixmap_id (GdkScreen *screen,
Atom atoms[G_N_ELEMENTS(atom_names)] = {0};
Atom type;
- int format;
+ int format, result;
unsigned long nitems, after;
unsigned char *data_root, *data_esetroot;
@@ -1503,20 +1503,24 @@ mate_bg_set_root_pixmap_id (GdkScreen *screen,
* This method is to avoid multiple round-trips to Xserver
*/
if (XInternAtoms (display, atom_names, G_N_ELEMENTS(atom_names), True, atoms) &&
- atoms[0] != None && atoms[1] != None)
- {
- XGetWindowProperty (display, xroot, atoms[0], 0L, 1L, False, AnyPropertyType,
- &type, &format, &nitems, &after, &data_root);
- if (data_root && type == XA_PIXMAP && format == 32 && nitems == 1)
- {
- XGetWindowProperty (display, xroot, atoms[1], 0L, 1L, False, AnyPropertyType,
- &type, &format, &nitems, &after, &data_esetroot);
- if (data_esetroot && type == XA_PIXMAP && format == 32 && nitems == 1)
- {
+ atoms[0] != None && atoms[1] != None) {
+ result = XGetWindowProperty (display, xroot, atoms[0], 0L, 1L,
+ False, AnyPropertyType,
+ &type, &format, &nitems, &after,
+ &data_root);
+
+ if (data_root != NULL && result == Success &&
+ type == XA_PIXMAP && format == 32 && nitems == 1) {
+ result = XGetWindowProperty (display, xroot, atoms[1],
+ 0L, 1L, False,
+ AnyPropertyType,
+ &type, &format, &nitems,
+ &after, &data_esetroot);
+
+ if (data_esetroot != NULL && result == Success &&
+ type == XA_PIXMAP && format == 32 && nitems == 1) {
Pixmap xrootpmap = *((Pixmap *) data_root);
Pixmap esetrootpmap = *((Pixmap *) data_esetroot);
- XFree (data_root);
- XFree (data_esetroot);
gdk_error_trap_push ();
if (xrootpmap && xrootpmap == esetrootpmap) {
@@ -1527,6 +1531,12 @@ mate_bg_set_root_pixmap_id (GdkScreen *screen,
}
gdk_error_trap_pop_ignored ();
}
+ if (data_esetroot != NULL) {
+ XFree (data_esetroot);
+ }
+ }
+ if (data_root != NULL) {
+ XFree (data_root);
}
}