summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Morell <rmorell@nvidia.com>2015-02-05 16:03:24 -0800
committerAaron Plattner <aplattner@nvidia.com>2015-02-09 09:39:47 -0800
commit20e953e15a58c01a2e78d204d5eba67be11fb488 (patch)
tree9d401a0dd0cb99d0b2eba55330145200fb96e58b
parentc7defe5f48f73313ca68396d550cd6d9d47d8501 (diff)
XStoreColors?: Fix transient display leak
On a system with many visuals, leaving the display connections open until test cleanup can cause the test to fail when the server reaches MAX_CLIENTS simultaneous connections. Signed-off-by: Robert Morell <rmorell@nvidia.com> Tested-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-by: Aaron Plattner <aplattner@nvidia.com> Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
-rw-r--r--xts5/Xlib7/XStoreColor.m10
-rw-r--r--xts5/Xlib7/XStoreColors.m10
2 files changed, 18 insertions, 2 deletions
diff --git a/xts5/Xlib7/XStoreColor.m b/xts5/Xlib7/XStoreColor.m
index 35109f37..ae9f13d6 100644
--- a/xts5/Xlib7/XStoreColor.m
+++ b/xts5/Xlib7/XStoreColor.m
@@ -377,10 +377,15 @@ unsigned long i;
if(i == maxsize(vp))
CHECK;
- disp2 = opendisplay();
+ disp2 = XOpenDisplay(config.display);
+ if (!disp2) {
+ delete("XOpenDisplay() failed.");
+ return;
+ }
if(XAllocColor(disp2, colormap, &testcol) == False) {
delete("XAllocColor() failed to allocate a r/o cell for a second client.");
+ XCloseDisplay(disp2);
return;
} else
CHECK;
@@ -397,6 +402,7 @@ unsigned long i;
if(XAllocColor(display, colormap, &testcol) == False) {
delete("XAllocColor() failed to allocate a r/o cell");
+ XCloseDisplay(disp2);
return;
} else
CHECK;
@@ -406,6 +412,8 @@ unsigned long i;
XCALL;
if(geterr() == BadAccess)
CHECK;
+
+ XCloseDisplay(disp2);
}
CHECKPASS(5*nvinf());
diff --git a/xts5/Xlib7/XStoreColors.m b/xts5/Xlib7/XStoreColors.m
index 729e7a43..ab68bd0a 100644
--- a/xts5/Xlib7/XStoreColors.m
+++ b/xts5/Xlib7/XStoreColors.m
@@ -564,10 +564,15 @@ unsigned long i;
}
trace("Open second client connection.");
- disp2 = opendisplay();
+ disp2 = XOpenDisplay(config.display);
+ if (!disp2) {
+ delete("XOpenDisplay() failed.");
+ return;
+ }
if(XAllocColor(disp2, colormap, &testcol[0]) == False) {
delete("XAllocColor() failed to allocate a r/o cell for a second client.");
+ XCloseDisplay(disp2);
return;
} else
CHECK;
@@ -581,6 +586,7 @@ unsigned long i;
if(XAllocColor(display, colormap, &testcol[1]) == False) {
delete("XAllocColor() failed to allocate a r/o cell");
+ XCloseDisplay(disp2);
return;
} else
CHECK;
@@ -591,6 +597,8 @@ unsigned long i;
XCALL;
if(geterr() == BadAccess)
CHECK;
+
+ XCloseDisplay(disp2);
}
CHECKPASS(6*nvinf());