summaryrefslogtreecommitdiff
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
commit5913c2cbe9f83d4fe163bf779b72a875bb20e271 (patch)
treedbd0eb7150c33a35a083f360ce5d6e128c712c98
parent1ad6371164a50b26ed6b1be2b341cb936855b63c (diff)
downloadmate-desktop-5913c2cbe9f83d4fe163bf779b72a875bb20e271.tar.bz2
mate-desktop-5913c2cbe9f83d4fe163bf779b72a875bb20e271.tar.xz
mate-bg: Avoid possible X11 data leaks
-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 e8c198a..c213354 100644
--- a/libmate-desktop/mate-bg.c
+++ b/libmate-desktop/mate-bg.c
@@ -1651,7 +1651,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;
@@ -1659,20 +1659,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) {
@@ -1686,6 +1690,12 @@ mate_bg_set_root_pixmap_id (GdkScreen *screen,
# endif
gdk_error_trap_pop_ignored ();
}
+ if (data_esetroot != NULL) {
+ XFree (data_esetroot);
+ }
+ }
+ if (data_root != NULL) {
+ XFree (data_root);
}
}