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

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

 



Owen Taylor <otaylor@xxxxxxxxxx> writes:

> 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.

I'm sorry, I should have included the full code. The function is below. It
crashes on the beginning of the for loop when it hits *prop.

gdb output:

Program received signal SIGSEGV, Segmentation fault.
0x0804d006 in cachewin (win=54526107) at cache.c:97
97            for (n = 1; *prop; n++)
1: name = (unsigned char *) 0x805e838 "konqueror"
(gdb) info locals
win = 1
new = (cacheinfo *) 0x805fc50
items = 9
left = 0
name = (unsigned char *) 0x805e838 "konqueror"
prop = (unsigned char *) 0x0
type = 31
format = 8
n = 1
cwin = 0


the function:

void cachewin(Window win)
{
  cacheinfo *new;
  unsigned long items, left;
  unsigned char *name, *prop;
  Atom type;
  int format, n;
  Window cwin;

  cwin = client_window(win);
  if (win != cwin)
    {
      cacheinfo *ci;
      for (ci = cachehead; ci; ci = ci->next)
	{
	  if (ci->win == cwin)
	    ci->parent = win;
	}
      return;
    }

  XSelectInput(dpy, cwin, EnterWindowMask | LeaveWindowMask);

  if (XGetWindowProperty(dpy, win, XA_WM_NAME, 0, 1000, False,
			 AnyPropertyType, &type, &format, &items,
			 &left, &name) != Success || !items)
    return;

  XGetWindowProperty(dpy, win, XA_WM_CLASS, 0, 1000, False, AnyPropertyType,
		     &type, &format, &items, &left, &prop);
  new = xmalloc(sizeof(cacheinfo) + (items * sizeof(char *)));
  new->next = cachehead;
  new->win = win;
  new->names[0] = name;
  if (items)
    {
      for (n = 1; *prop; n++)
	{
	  new->names[n] = prop;
	  prop = strchr(prop, '\0') + 1;
	}
      new->numnames = n;
    }
  else
    new->numnames = 1;
  cachehead = new;
}




-- 
greg

_______________________________________________
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