diff options
| author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-03-09 11:04:37 -0800 |
|---|---|---|
| committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-05-09 18:59:53 -0700 |
| commit | 192bbb9e2fc45df4e17b35b6d14ea0eb418dbd39 (patch) | |
| tree | ef25a5b1b7f9ed85f10b2f69816433d8e76cee70 /src/GetProp.c | |
| parent | db1b1c871da29aa0545182bf888df81627f165a5 (diff) | |
Make XGetWindowProperty() always initialize returned values
Avoids memory corruption and other errors when callers access them
without checking to see if XGetWindowProperty() returned an error value.
Callers are still required to check for errors, this just reduces the
damage when they don't.
Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Diffstat (limited to 'src/GetProp.c')
| -rw-r--r-- | src/GetProp.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/GetProp.c b/src/GetProp.c index ae14edcf..9eb422ee 100644 --- a/src/GetProp.c +++ b/src/GetProp.c @@ -49,6 +49,13 @@ XGetWindowProperty( register xGetPropertyReq *req; xError error = {0}; + /* 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 = *bytesafter = 0L; + *prop = (unsigned char *) NULL; + LockDisplay(dpy); GetReq (GetProperty, req); req->window = w; @@ -65,7 +72,6 @@ XGetWindowProperty( return (1); /* not Success */ } - *prop = (unsigned char *) NULL; if (reply.propertyType != None) { unsigned long nbytes, netbytes; int format = reply.format; |
