...and fix an unlikely memory leak.
authorjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 5 Jan 2009 01:15:06 +0000 (01:15 +0000)
committerjacob <jacob@cda61777-01e9-0310-a592-d414129be87e>
Mon, 5 Jan 2009 01:15:06 +0000 (01:15 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@8384 cda61777-01e9-0310-a592-d414129be87e

unix/ux_x11.c

index 4126d5b..5794d31 100644 (file)
@@ -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;
            }