summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArnaud Fontaine <arnau@debian.org>2011-03-29 22:56:28 +0159
committerColin Guthrie <colin@mageia.org>2011-04-30 14:26:45 +0100
commitadb16f9ff42008c5b8f76133d8879fc15a82533f (patch)
treec400f5dc40bc8e6f74b0898a5c4bb0130f8f3c32 /src
parent2f7eb35f370bb79c12f229d109fc4dd2b74c9f47 (diff)
x11: More XCB fixes.
Commit 65ef80b fixed building with xcb-util >= 0.3.8, but the reply is never checked (possible SIGSEGV if the reply is NULL) nor freed (memory leak at each call of the functions). Also, remove include and dependencies on xcb-atom, as it was only meaningful for xcb_atom_get() and STRING, and depend instead on xcb >= 1.6 for XCB_ATOM_STRING.
Diffstat (limited to 'src')
-rw-r--r--src/pulsecore/x11prop.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index 99ea55df..baf5b018 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -30,7 +30,6 @@
#include <pulsecore/macro.h>
#include <xcb/xproto.h>
-#include <xcb/xcb_atom.h>
#define PA_XCB_FORMAT 8
@@ -49,7 +48,6 @@ static xcb_screen_t *screen_of_display(xcb_connection_t *xcb, int screen) {
void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const char *data) {
xcb_screen_t *xs;
- xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
pa_assert(xcb);
@@ -57,26 +55,36 @@ void pa_x11_set_prop(xcb_connection_t *xcb, int screen, const char *name, const
pa_assert(data);
if ((xs = screen_of_display(xcb, screen))) {
- cookie = xcb_intern_atom(xcb, 0, strlen(name), name);
- reply = xcb_intern_atom_reply(xcb, cookie, NULL);
+ reply = xcb_intern_atom_reply(xcb,
+ xcb_intern_atom(xcb, 0, strlen(name), name),
+ NULL);
- xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, xs->root, reply->atom, XCB_ATOM_STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
+ if (reply) {
+ xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, xs->root, reply->atom,
+ XCB_ATOM_STRING, PA_XCB_FORMAT,
+ (int) strlen(data), (const void*) data);
+
+ free(reply);
+ }
}
}
void pa_x11_del_prop(xcb_connection_t *xcb, int screen, const char *name) {
xcb_screen_t *xs;
- xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
pa_assert(xcb);
pa_assert(name);
if ((xs = screen_of_display(xcb, screen))) {
- cookie = xcb_intern_atom(xcb, 0, strlen(name), name);
- reply = xcb_intern_atom_reply(xcb, cookie, NULL);
-
- xcb_delete_property(xcb, xs->root, reply->atom);
+ reply = xcb_intern_atom_reply(xcb,
+ xcb_intern_atom(xcb, 0, strlen(name), name),
+ NULL);
+
+ if (reply) {
+ xcb_delete_property(xcb, xs->root, reply->atom);
+ free(reply);
+ }
}
}
@@ -86,7 +94,6 @@ char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char
xcb_get_property_cookie_t req;
xcb_get_property_reply_t* prop = NULL;
xcb_screen_t *xs;
- xcb_intern_atom_cookie_t cookie;
xcb_intern_atom_reply_t *reply;
pa_assert(xcb);
@@ -105,10 +112,15 @@ char* pa_x11_get_prop(xcb_connection_t *xcb, int screen, const char *name, char
xs = screen_of_display(xcb, 0);
if (xs) {
- cookie = xcb_intern_atom(xcb, 0, strlen(name), name);
- reply = xcb_intern_atom_reply(xcb, cookie, NULL);
+ reply = xcb_intern_atom_reply(xcb,
+ xcb_intern_atom(xcb, 0, strlen(name), name),
+ NULL);
+
+ if (!reply)
+ goto finish;
req = xcb_get_property(xcb, 0, xs->root, reply->atom, XCB_ATOM_STRING, 0, (uint32_t)(l-1));
+ free(reply);
prop = xcb_get_property_reply(xcb, req, NULL);
if (!prop)