ypserv/ypserv-2.13-yplib-memleak.patch
cvsdist 39e988d63d auto-import changelog data from ypserv-2.13-4.src.rpm
Tue Aug 31 2004 Steve Dickson <SteveD@RedHat.com>
- Zeroed out the ypxfr response buffer so allocated memory is not freed
    with the transfer fails
Sat Jun 19 2004 Steve Dickson <SteveD@RedHat.com>
- Closed a memory leak in GDBM database routines (bz 120980)
2004-09-09 15:21:45 +00:00

62 lines
2.4 KiB
Diff

--- ypserv-2.13/lib/yp_db.c.org 2004-04-14 07:47:02.000000000 -0400
+++ ypserv-2.13/lib/yp_db.c 2004-06-19 08:48:33.000000000 -0400
@@ -200,6 +200,7 @@ ypdb_close_all (void)
fast_open_files[i].map, i);
free (fast_open_files[i].domain);
free (fast_open_files[i].map);
+ fast_open_files[i].domain = fast_open_files[i].map = NULL;
_db_close (fast_open_files[i].dbp);
fast_open_files[i].dbp = NULL;
fast_open_files[i].flag = 0;
@@ -232,8 +233,11 @@ ypdb_close (DB_FILE file)
log_msg ("ypdb_MUST_close (%s/%s|%d)",
fast_open_files[i].domain,
fast_open_files[i].map, i);
- free (fast_open_files[i].domain);
- free (fast_open_files[i].map);
+ if (fast_open_files[i].domain != NULL)
+ free (fast_open_files[i].domain);
+ if (fast_open_files[i].map != NULL)
+ free (fast_open_files[i].map);
+ fast_open_files[i].domain = fast_open_files[i].map = NULL;
_db_close (fast_open_files[i].dbp);
fast_open_files[i].dbp = NULL;
fast_open_files[i].flag = 0;
@@ -279,6 +283,10 @@ ypdb_open (const char *domain, const cha
fast_open_init = 0;
for (i = 0; i < cached_filehandles; i++)
{
+ if (fast_open_files[i].domain != NULL)
+ free (fast_open_files[i].domain);
+ if (fast_open_files[i].map != NULL)
+ free (fast_open_files[i].map);
fast_open_files[i].domain =
fast_open_files[i].map = NULL;
fast_open_files[i].dbp = (DB_FILE) NULL;
@@ -334,7 +342,11 @@ ypdb_open (const char *domain, const cha
Fopen tmp;
if ((fast_open_files[i].dbp = _db_open (domain, map)) == NULL)
- return NULL;
+ return NULL;
+ if (fast_open_files[i].domain != NULL)
+ free(fast_open_files[i].domain);
+ if (fast_open_files[i].map != NULL)
+ free(fast_open_files[i].map);
fast_open_files[i].domain = strdup (domain);
fast_open_files[i].map = strdup (map);
fast_open_files[i].flag |= F_OPEN_FLAG;
@@ -375,8 +387,10 @@ ypdb_open (const char *domain, const cha
fast_open_files[i].map, i);
log_msg ("Opening: %s/%s (%d)", domain, map, i);
}
- free (fast_open_files[i].domain);
- free (fast_open_files[i].map);
+ if (fast_open_files[i].domain != NULL)
+ free (fast_open_files[i].domain);
+ if (fast_open_files[i].map != NULL)
+ free (fast_open_files[i].map);
_db_close (fast_open_files[i].dbp);
fast_open_files[i].domain = strdup (domain);