Skip to content

Commit 93e904a

Browse files
committed
upstream: memory leak on error path; bz3821
OpenBSD-Commit-ID: 65577596a15ad6dd9a1ab3fc24c1c31303ee6e2b
1 parent 55b38ff commit 93e904a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

misc-agent.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ socket_is_stale(const char *path)
266266
void
267267
agent_cleanup_stale(const char *homedir, int ignore_hosthash)
268268
{
269-
DIR *d;
269+
DIR *d = NULL;
270270
struct dirent *dp;
271271
struct stat sb;
272-
char *prefix = NULL, *dirpath, *path;
272+
char *prefix = NULL, *dirpath = NULL, *path;
273273
struct timespec now, sub, *mtimp = NULL;
274274

275275
/* Only consider sockets last modified > 1 hour ago */
@@ -295,8 +295,7 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
295295
if ((d = opendir(dirpath)) == NULL) {
296296
if (errno != ENOENT)
297297
error_f("opendir \"%s\": %s", dirpath, strerror(errno));
298-
free(dirpath);
299-
return;
298+
goto out;
300299
}
301300
while ((dp = readdir(d)) != NULL) {
302301
if (dp->d_type != DT_SOCK && dp->d_type != DT_UNKNOWN)
@@ -334,8 +333,9 @@ agent_cleanup_stale(const char *homedir, int ignore_hosthash)
334333
}
335334
free(path);
336335
}
337-
closedir(d);
336+
out:
337+
if (d != NULL)
338+
closedir(d);
338339
free(dirpath);
339340
free(prefix);
340341
}
341-

0 commit comments

Comments
 (0)