mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-06 17:40:16 +01:00
Check return value of XGetWindowProperty in x11_get_address
Reviewed-by: Thiago Macieira <thiago@kde.org> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29881
This commit is contained in:
parent
e2be7b92a6
commit
79b4e478d7
1 changed files with 9 additions and 8 deletions
|
|
@ -293,6 +293,7 @@ init_x_atoms (Display *display)
|
|||
int
|
||||
x11_get_address (char **paddress, pid_t *pid, long *wid)
|
||||
{
|
||||
int result;
|
||||
Atom type;
|
||||
Window owner;
|
||||
int format;
|
||||
|
|
@ -310,10 +311,10 @@ x11_get_address (char **paddress, pid_t *pid, long *wid)
|
|||
*wid = (long) owner;
|
||||
|
||||
/* get the bus address */
|
||||
XGetWindowProperty (xdisplay, owner, address_atom, 0, 1024, False,
|
||||
XA_STRING, &type, &format, &items, &after,
|
||||
(unsigned char **) &data);
|
||||
if (type == None || after != 0 || data == NULL || format != 8)
|
||||
result = XGetWindowProperty (xdisplay, owner, address_atom, 0, 1024, False,
|
||||
XA_STRING, &type, &format, &items, &after,
|
||||
(unsigned char **) &data);
|
||||
if (result != Success || type == None || after != 0 || data == NULL || format != 8)
|
||||
return FALSE; /* error */
|
||||
|
||||
*paddress = xstrdup (data);
|
||||
|
|
@ -323,10 +324,10 @@ x11_get_address (char **paddress, pid_t *pid, long *wid)
|
|||
if (pid != NULL)
|
||||
{
|
||||
*pid = 0;
|
||||
XGetWindowProperty (xdisplay, owner, pid_atom, 0, sizeof pid, False,
|
||||
XA_CARDINAL, &type, &format, &items, &after,
|
||||
(unsigned char **) &data);
|
||||
if (type != None && after == 0 && data != NULL && format == 32)
|
||||
result = XGetWindowProperty (xdisplay, owner, pid_atom, 0, sizeof pid, False,
|
||||
XA_CARDINAL, &type, &format, &items, &after,
|
||||
(unsigned char **) &data);
|
||||
if (result == Success && type != None && after == 0 && data != NULL && format == 32)
|
||||
*pid = (pid_t) *(long*) data;
|
||||
XFree (data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue