Commit c90f7449 authored by Alan Coopersmith's avatar Alan Coopersmith

Make XRRGet*Property() always initialize returned values

Avoids memory corruption and other errors when callers access them
without checking to see if the calls returned an error value.

Callers are still required to check for errors, this just reduces the
damage when they don't.

(Same as reported against libX11 XGetWindowProperty by Ilja Van Sprundel)
Signed-off-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 4254bf0e
......@@ -259,6 +259,13 @@ XRRGetOutputProperty (Display *dpy, RROutput output,
xRRGetOutputPropertyReq *req;
unsigned long nbytes, rbytes;
/* Always initialize return values, in case callers fail to initialize
them and fail to check the return code for an error. */
*actual_type = None;
*actual_format = 0;
*nitems = *bytes_after = 0L;
*prop = (unsigned char *) NULL;
RRCheckExtension (dpy, info, 1);
LockDisplay (dpy);
......@@ -280,7 +287,6 @@ XRRGetOutputProperty (Display *dpy, RROutput output,
return ((xError *)&rep)->errorCode;
}
*prop = (unsigned char *) NULL;
if (rep.propertyType != None) {
int format = rep.format;
......
......@@ -259,6 +259,13 @@ XRRGetProviderProperty (Display *dpy, RRProvider provider,
xRRGetProviderPropertyReq *req;
unsigned long nbytes, rbytes;
/* Always initialize return values, in case callers fail to initialize
them and fail to check the return code for an error. */
*actual_type = None;
*actual_format = 0;
*nitems = *bytes_after = 0L;
*prop = (unsigned char *) NULL;
RRCheckExtension (dpy, info, 1);
LockDisplay (dpy);
......@@ -280,7 +287,6 @@ XRRGetProviderProperty (Display *dpy, RRProvider provider,
return ((xError *)&rep)->errorCode;
}
*prop = (unsigned char *) NULL;
if (rep.propertyType != None) {
int format = rep.format;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment