diff options
author | Eric Anholt <eric@anholt.net> | 2007-01-16 13:10:49 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2007-01-16 13:11:36 -0800 |
commit | 382b7a3cfabdd37a6231e18a2ac92bc8a3722b79 (patch) | |
tree | 917408a1d95eb8ce8c51a6aaa49a5c9e6fba126e | |
parent | 36a4a633a93a89bd854f49e670777925c9751de3 (diff) |
Return a valid property info even if we lack valid value sets.
Previously, XRRQueryOutputProperty90 would return an uninitialized pointer if
num_values was 0.
-rw-r--r-- | src/XrrProperty.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/XrrProperty.c b/src/XrrProperty.c index 5367e1e..4d5dd1e 100644 --- a/src/XrrProperty.c +++ b/src/XrrProperty.c @@ -106,25 +106,27 @@ XRRQueryOutputProperty (Display *dpy, RROutput output, Atom property) return NULL; } - if (rep.length) { - nbytes = rep.length * sizeof (long); - netbytes = rep.length << 2; + nbytes = rep.length * sizeof (long); + netbytes = rep.length << 2; - prop_info = (XRRPropertyInfo *) Xmalloc (nbytes + - sizeof (XRRPropertyInfo)); - if (prop_info == NULL) { - _XEatData (dpy, netbytes); - UnlockDisplay (dpy); - SyncHandle (); - return NULL; - } - prop_info->pending = rep.pending; - prop_info->range = rep.range; - prop_info->immutable = rep.immutable; - prop_info->num_values = rep.length; - prop_info->values = (long *) (prop_info + 1); + prop_info = (XRRPropertyInfo *) Xmalloc (nbytes + + sizeof (XRRPropertyInfo)); + if (prop_info == NULL) { + _XEatData (dpy, netbytes); + UnlockDisplay (dpy); + SyncHandle (); + return NULL; + } + prop_info->pending = rep.pending; + prop_info->range = rep.range; + prop_info->immutable = rep.immutable; + prop_info->num_values = rep.length; + if (rep.length != 0) { + prop_info->values = (long *) (prop_info + 1); _XRead32 (dpy, prop_info->values, nbytes); + } else { + prop_info->values = NULL; } UnlockDisplay (dpy); |