1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 18:07:59 +00:00

...and fix an unlikely memory leak.

[originally from svn r8384]
This commit is contained in:
Jacob Nevins 2009-01-05 01:15:06 +00:00
parent 030046a2a8
commit 51bceb0c9a

View File

@ -37,12 +37,14 @@ void platform_get_x11_auth(struct X11Display *disp, const Config *cfg)
int len; int len;
sfree(disp->hostname); sfree(disp->hostname);
disp->hostname = NULL;
len = 128; len = 128;
do { do {
len *= 2; len *= 2;
disp->hostname = snewn(len, char); disp->hostname = sresize(disp->hostname, len, char);
if ((gethostname(disp->hostname, len) < 0) && if ((gethostname(disp->hostname, len) < 0) &&
(errno != ENAMETOOLONG)) { (errno != ENAMETOOLONG)) {
sfree(disp->hostname);
disp->hostname = NULL; disp->hostname = NULL;
return; return;
} }