Bug#568339: patch for three compiler warnings

2010-02-14 Thread Alex Perry
This patch resolves the three compiler warnings in the function
xft_setfont at draw.c:5476 that was triggering the segfault in
libfontconfig via libXft.  MGP now runs the presentation on which I
originally also observed the crash.  Could we get those into a debian
patched release please?

$ diff -u mgp-1.13a+upstream20090219/draw.c mgp-1.13a+local/draw.c
--- mgp-1.13a+upstream20090219/draw.c   2009-02-15 03:35:19.0 -0800
+++ mgp-1.13a+local/draw.c  2010-02-14 14:42:30.0 -0800
@@ -5425,7 +5425,6 @@
char *p, *p2;
char style[100];
char font[100];
-   int stlen;

bzero(style, sizeof(style));
bzero(font, sizeof(font));
@@ -5471,12 +5470,12 @@
XFT_FAMILY, XftTypeString, font,
XFT_ENCODING, XftTypeString, registry,
XFT_STYLE, XftTypeString, style,
-   XFT_PIXEL_SIZE, XftTypeDouble, (float)csize, 0);
+   XFT_PIXEL_SIZE, XftTypeDouble, (float)csize, (char*)0);
} else {
xftfont = XftFontOpen(display, screen,
XFT_FAMILY, XftTypeString, font,
XFT_ENCODING, XftTypeString, registry,
-   XFT_PIXEL_SIZE, XftTypeDouble, (float)csize, 0);
+   XFT_PIXEL_SIZE, XftTypeDouble, (float)csize, (char*)0);
}
if (xftfont == 0) {
free(xfont);



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/161e37d01002141501g13f2052bs65f90a6865846...@mail.gmail.com



Bug#325689: xloadimage: client leakage clears if type casts are tidied up (patch attached)

2008-02-02 Thread Alex Perry
tags 325689 + patch
thanks

Without this, I leak resources from the X server with every -onroot,
as can be verified using xrestop, while with this there's no leak.
The extra diagnostics are strictly speaking not necessary,
but really are a good idea since we're modifying the shared root.


--- xloadimage-4.1.orig/root.c  2008-02-02 15:18:36.0 -0800
+++ xloadimage-4.1/root.c   2008-02-02 16:04:19.0 -0800
@@ -16,23 +16,6 @@

 #define RETAIN_PROP_NAME   _XSETROOT_ID

-void updateProperty(dpy, w, name, type, format, data, nelem)
- Display   *dpy;
- Windoww;
- char  *name;
- Atom  type;
- int   format;
- int   data;
- int   nelem;
-{
-  /* intern the property name */
-  Atom atom = XInternAtom(dpy, name, 0);
-
-  /* create or replace the property */
-  XChangeProperty(dpy, w, atom, type, format, PropModeReplace,
- (unsigned char *)data, nelem);
-}
-

 /* Sets the close-down mode of the client to 'RetainPermanent'
  * so all client resources will be preserved after the client
@@ -47,9 +30,15 @@
 {
   /* create dummy resource */
   Pixmap pm= XCreatePixmap(dpy, w, 1, 1, 1);
+  unsigned char *data = (unsigned char *) pm;

-  /* create/replace the property */
-  updateProperty(dpy, w, RETAIN_PROP_NAME, XA_PIXMAP, 32, (int)pm, 1);
+  /* intern the property name */
+  char *name = RETAIN_PROP_NAME;
+  Atom atom = XInternAtom(dpy, name, 0);
+
+  /* create or replace the property */
+  XChangeProperty(dpy, w, atom, XA_PIXMAP, 32, PropModeReplace,
+ data, sizeof(Pixmap)/4);

   /* retain all client resources until explicitly killed */
   XSetCloseDownMode(dpy, RetainPermanent);
@@ -65,32 +54,57 @@
  Display   *dpy;
  Windoww;
 {
-  Pixmap *pm;  
-  Atom actual_type;/* NOTUSED */
+  Pixmap *pm;
+  unsigned char *charpm;
+  Atom actual_type;
   int  format;
-  int  nitems;
-  int  bytes_after;
+  unsigned longnitems;
+  unsigned longbytes_after;
+  int   returncode;

   /* intern the property name */
   Atom atom = XInternAtom(dpy, RETAIN_PROP_NAME, 0);
+  fprintf(stderr, info: freePrevious );

   /* look for existing resource allocation */
-  if ((XGetWindowProperty(dpy, w, atom, 0, 1, 1/*delete*/,
- AnyPropertyType, actual_type, format, (unsigned 
long *)nitems,
- (unsigned long *)bytes_after, (unsigned char **)pm) 
== Success) 
-  nitems == 1) {
-if ((actual_type == XA_PIXMAP)  (format == 32) 
-   (nitems == 1)  (bytes_after == 0)) {
-  /* blast it away */
-  XKillClient(dpy, (XID) *pm);
-  XFree((char *)pm);
-}
-else if (actual_type != None) {
-  fprintf(stderr,
- %s: warning: invalid format encountered for property %s\n,
- RETAIN_PROP_NAME, xloadimage);
-}
-  }
+  nitems = sizeof(Pixmap)/4;
+  returncode = XGetWindowProperty(dpy, w, atom,
+ 0, nitems, 1/*delete*/,
+XA_PIXMAP, actual_type,
+format, nitems,
+bytes_after, charpm);
+  if (returncode != Success) {
+fprintf(stderr, failed to look for %s with return code %i.\n,
+RETAIN_PROP_NAME, returncode);
+return;
+  }
+
+  /* Check if the property was found */
+  if (actual_type == None) {
+fprintf(stderr, didn't find evidence of prior run.\n);
+return;
+  }
+
+  /* Make sure the dummy value is still present */
+  if (actual_type != XA_PIXMAP) {
+fprintf(stderr, found wrong data type - skipped.\n);
+return;
+  }
+
+  /* Check size, in case we're a different architecture */
+  if ((nitems != sizeof(Pixmap)/4) ||
+  (format != 32) ||
+  (bytes_after != 0)) {
+fprintf(stderr, saw wrong %li / word size %i / architecture %li.\n,
+bytes_after, format, nitems);
+return;
+  }
+
+  /* blast it away */
+  pm = (Pixmap*) charpm;
+  XKillClient(dpy, (XID) *pm);
+  XFree(charpm);
+  fprintf(stderr, called KillClient and XFree for its prior image.\n);
 }

 #if FIND_DEC_ROOTWINDOW
@@ -185,15 +199,16 @@
 for(i = 0; i  numChildren; i++) {
   Atom actual_type;
   int actual_format;
-  long nitems, bytesafter;
-  Window *newRoot = NULL;
+  unsigned long nitems, bytesafter;
+  unsigned char *newRoot = 0;

-  if (XGetWindowProperty (disp, children[i], __SWM_VROOT,0,1,
- False, XA_WINDOW, actual_type, actual_format,
- (unsigned long *)nitems, (unsigned long 
*)bytesafter,
- (unsigned char **) newRoot) ==
- Success  newRoot) {
-   root = *newRoot;
+  if ((XGetWindowProperty (disp, children[i], __SWM_VROOT,0,1,
+ False, XA_WINDOW,
+ actual_type, actual_format,
+ nitems, bytesafter, newRoot)
+  == Success) 
+ newRoot) {
+   root = *((Window*)