Re: [XFree86] XGetWindowProperty returning null prop_return but nonzero nitems_return

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2003-10-10 at 11:47, Greg Stark wrote:
> I have a program here that's always worked fine in the past that has suddenly
> started crashing recently. I've tracked the crash down to a XGetWindowProperty
> call that is returning a NULL prop_return. The weird thing is that
> nitems_return is non-zero (9 in fact) though num_prop_return is zero.
> 
> Maybe I misunderstand the API here, but it seems the author read the same man
> page and came to the same conclusion. He only checks for a nonzero
> nitems_return before dereferencing prop_return. 
> 
> The weird thing is it only seems to happen for KDE windows, not other windows.
> 
> Is this a bug in xlib? Or in this application? Is there a documentation bug?
> 
> XGetWindowProperty(dpy, win, XA_WM_NAME, 0, 1000, False,
>                    AnyPropertyType, &type, &format, &items,
>                    &left, &name)

The best way to check for the success of XGetWindowProperty()
with a type of AnyPropertyType is to check that the actual_type
is not None.

Checking the returned nitems doesn't work because an empty property
will result in a block of length 1 being allocated, but a
nitems of 0. So, checking nitems != 0 will result in memory
leaks.

However, that doesn't explain your behavior above. It's either
an Xserver or Xlib bug (unlikely, IMO, this stuff doesn't change
much at all), or a bug in the application code outside of what
you have quoted.

One possibility that comes to mind is that the author is trapping X
errors but not looking at the return value from XGetWindowProperty().
If you are trapping X errors, then you need to write;

 if (XGetWindowProperty (...) != Success) {
 }

Regards,
						Owen


_______________________________________________
XFree86 mailing list
XFree86@xxxxxxxxxxx
http://XFree86.Org/mailman/listinfo/xfree86

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux