From 382b7a3cfabdd37a6231e18a2ac92bc8a3722b79 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 16 Jan 2007 13:10:49 -0800 Subject: Return a valid property info even if we lack valid value sets. Previously, XRRQueryOutputProperty90 would return an uninitialized pointer if num_values was 0. --- src/XrrProperty.c | 34 ++++++++++++++++++---------------- 1 file 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); -- cgit v1.2.1