From 51bceb0c9ae16dda950429a3f7c71654c885c176 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Mon, 5 Jan 2009 01:15:06 +0000 Subject: [PATCH] ...and fix an unlikely memory leak. [originally from svn r8384] --- unix/ux_x11.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unix/ux_x11.c b/unix/ux_x11.c index 4126d5b7..5794d315 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -37,12 +37,14 @@ void platform_get_x11_auth(struct X11Display *disp, const Config *cfg) int len; sfree(disp->hostname); + disp->hostname = NULL; len = 128; do { len *= 2; - disp->hostname = snewn(len, char); + disp->hostname = sresize(disp->hostname, len, char); if ((gethostname(disp->hostname, len) < 0) && (errno != ENAMETOOLONG)) { + sfree(disp->hostname); disp->hostname = NULL; return; } -- 2.45.2