summaryrefslogtreecommitdiff
path: root/net/nxserver/files/patch-nx-X11-programs-Xserver-nxagent-Pixmap.c
blob: ad00e8098bbd5a72a311e8a48bf104f89c6ac79c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c.orig	2006-11-09 12:18:00.000000000 -0455
+++ nx-X11/programs/Xserver/hw/nxagent/Pixmap.c
@@ -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)