All pastes #366798 Raw Edit

Miscellany

public text v1 · immutable
#366798 ·published 2007-02-21 22:39 UTC
rendered paste body
diff -uBbr new/nx-X11/programs/Xserver/hw/nxagent/Atoms.c nx-X11/programs/Xserver/hw/nxagent/Atoms.c
--- new/nx-X11/programs/Xserver/hw/nxagent/Atoms.c	2006-04-18 11:40:18.000000000 -0355
+++ nx-X11/programs/Xserver/hw/nxagent/Atoms.c	2007-02-19 12:54:51.000000000 -0455
@@ -785,6 +785,8 @@
 
     nxagentWriteAtom(local, remote, string, True);
 
+    XFree(string);
+
     return local;
   }
 
diff -uBbr new/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
--- new/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c	2006-11-09 12:22:35.000000000 -0455
+++ nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c	2007-02-21 13:23:59.000000000 -0455
@@ -2521,7 +2521,7 @@
 		err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
 		    ((pointer) c->client, fpe, c->current.pattern,
 		     c->current.patlen, c->current.max_names - c->names->nnames,
-		     &c->current.private);
+		     &c->current.private); /* FIXME: returned mem c->current.private (needed by list_next_font_or_alias) may never be freed */
 		if (err == Suspended) {
 		    if (!c->slept) {
 			ClientSleep(client,
diff -uBbr new/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c nx-X11/programs/Xserver/hw/nxagent/Pixmap.c
--- new/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c	2006-11-09 12:18:00.000000000 -0455
+++ nx-X11/programs/Xserver/hw/nxagent/Pixmap.c	2007-02-21 13:28:54.000000000 -0455
@@ -1115,6 +1115,7 @@
     {
       FatalError("XGetImage: Failed.\n");
 
+      free(data);
       return False;
     }
 
@@ -1600,6 +1601,7 @@
         fprintf(stderr, "nxagentSynchronizeDrawableData: WARNING! Failed to create the temporary GC.\n");
         #endif
 
+        xfree(data);
         return 0;
       }
 
@@ -1661,6 +1663,7 @@
           fprintf(stderr, "nxagentSynchronizeDrawableData: WARNING! Failed to create the temporary GC.\n");
           #endif
 
+          xfree(data);
           return 0;
         }
 
@@ -1772,6 +1775,7 @@
   int useExtents;
   int imageLength, corruptedLength;
   int corruptedWidth, corruptedHeight;
+  int ret = 0; /* Used by error handling. 0 is error(?, based on previous code) */
 
   #ifdef TEST
   static int totalLength;
@@ -1812,7 +1816,7 @@
                             (void *) pDrawable);
     #endif
 
-    return 0;
+    goto SR_FREE_CLIP;
   }
 
   /*
@@ -1836,7 +1840,7 @@
                               (void *) pDrawable);
       #endif
 
-      return 0;
+      goto SR_FREE_CLIP;
     }
   }
 
@@ -1861,7 +1865,7 @@
     fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Failed to allocate memory for the operation.\n");
     #endif
 
-    return 0;
+    goto SR_FREE_CLIP;
   }
 
   pSrcDrawable = (pDrawable -> type == DRAWABLE_PIXMAP ?
@@ -1876,7 +1880,7 @@
     fprintf(stderr, "nxagentSynchronizeRegion: WARNING! Failed to create the temporary GC.\n");
     #endif
 
-    return 0;
+    goto SR_FREE_XALLOC;
   }
 
   ValidateGC(pDrawable, pGC);
@@ -1935,7 +1939,7 @@
 
     #endif
 
-    return 1;
+    goto SR_FREE_GC;
   }
 
   /*
@@ -2029,13 +2033,17 @@
 
   nxagentGCTrap = saveTrap;
 
-  nxagentFreeRegion(pDrawable, clipRegion);
+SR_FREE_GC:
+  ret = 1;
+  FreeScratchGC(pGC);
 
+SR_FREE_XALLOC:
   xfree(data);
 
-  FreeScratchGC(pGC);
+SR_FREE_CLIP:
+  nxagentFreeRegion(pDrawable, clipRegion);
 
-  return 1;
+  return ret;
 }
 
 void nxagentSynchronizeBox(DrawablePtr pDrawable, BoxPtr pBox)