[PATCH xts] XStoreColors?: Fix transient display leak

Aaron Plattner aplattner at nvidia.com
Mon Feb 9 09:41:54 PST 2015


On 02/05/2015 04:03 PM, Robert Morell wrote:
> 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 at nvidia.com>
> ---
>   xts5/Xlib7/XStoreColor.m  | 10 +++++++++-
>   xts5/Xlib7/XStoreColors.m | 10 +++++++++-
>   2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/xts5/Xlib7/XStoreColor.m b/xts5/Xlib7/XStoreColor.m
> index 35109f37ebb8..ae9f13d6325a 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 729e7a43c185..ab68bd0a076b 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());

Thanks for fixing this!

Pushed:
remote: Updating patchwork state for 
http://patchwork.freedesktop.org/project/Xorg/list/
remote: I: patch #41829 updated using rev 
20e953e15a58c01a2e78d204d5eba67be11fb488.
remote: I: 1 patch(es) updated to state Accepted.
To git.freedesktop.org:/git/xorg/test/xts.git
    c7defe5f48f7..20e953e15a58  master -> master



More information about the xorg-devel mailing list