* [SEMANAGE] Fix memory leak in cache error path
@ 2006-01-17 19:26 Ivan Gyurdiev
0 siblings, 0 replies; only message in thread
From: Ivan Gyurdiev @ 2006-01-17 19:26 UTC (permalink / raw)
To: SELinux List; +Cc: Stephen Smalley
[-- Attachment #1: Type: text/plain, Size: 87 bytes --]
The llist-based cache() implementations leak memory in the error path -
fix that...
[-- Attachment #2: libsemanage.cache_err_memory_leak.diff --]
[-- Type: text/x-patch, Size: 3016 bytes --]
diff -Naurp --exclude-from excludes old/libsemanage/src/database_activedb.c new/libsemanage/src/database_activedb.c
--- old/libsemanage/src/database_activedb.c 2006-01-17 09:11:06.000000000 -0700
+++ new/libsemanage/src/database_activedb.c 2006-01-17 12:15:44.000000000 -0700
@@ -44,7 +44,10 @@ static int dbase_activedb_cache(
if (!dbase_llist_needs_resync(handle, &dbase->llist))
return STATUS_SUCCESS;
+ /* Update cache serial */
dbase_llist_cache_init(&dbase->llist);
+ if (dbase_llist_set_serial(handle, &dbase->llist) < 0)
+ goto err;
/* Fetch the entire list */
if (ratable->read_list(handle, &records, &rcount) < 0)
@@ -57,10 +60,6 @@ static int dbase_activedb_cache(
rtable->free(records[i]);
}
- /* Update cache serial */
- if (dbase_llist_set_serial(handle, &dbase->llist) < 0)
- goto err;
-
free(records);
return STATUS_SUCCESS;
@@ -68,6 +67,7 @@ static int dbase_activedb_cache(
ERR(handle, "could not cache active database");
for (; i < rcount; i++)
rtable->free(records[i]);
+ dbase_llist_drop_cache(&dbase->llist);
free(records);
return STATUS_ERR;
}
diff -Naurp --exclude-from excludes old/libsemanage/src/database_file.c new/libsemanage/src/database_file.c
--- old/libsemanage/src/database_file.c 2006-01-17 11:40:12.000000000 -0700
+++ new/libsemanage/src/database_file.c 2006-01-17 12:16:19.000000000 -0700
@@ -76,7 +76,10 @@ static int dbase_file_cache(
if (!dbase_llist_needs_resync(handle, &dbase->llist))
return STATUS_SUCCESS;
+ /* Update cache serial */
dbase_llist_cache_init(&dbase->llist);
+ if (dbase_llist_set_serial(handle, &dbase->llist) < 0)
+ goto err;
if (construct_filename(handle, dbase, &fname) < 0)
goto err;
@@ -115,10 +118,6 @@ static int dbase_file_cache(
} while (pstatus != STATUS_NODATA);
- /* Update cache serial */
- if (dbase_llist_set_serial(handle, &dbase->llist) < 0)
- goto err;
-
rtable->free(process_record);
parse_close(parse_info);
parse_release(parse_info);
@@ -130,6 +129,7 @@ static int dbase_file_cache(
rtable->free(process_record);
parse_close(parse_info);
parse_release(parse_info);
+ dbase_llist_drop_cache(&dbase->llist);
free(fname);
return STATUS_ERR;
}
diff -Naurp --exclude-from excludes old/libsemanage/src/database_join.c new/libsemanage/src/database_join.c
--- old/libsemanage/src/database_join.c 2006-01-17 09:11:06.000000000 -0700
+++ new/libsemanage/src/database_join.c 2006-01-17 12:16:58.000000000 -0700
@@ -58,7 +58,10 @@ static int dbase_join_cache(
if (!dbase_llist_needs_resync(handle, &dbase->llist))
return STATUS_SUCCESS;
+ /* Update cache serial */
dbase_llist_cache_init(&dbase->llist);
+ if (dbase_llist_set_serial(handle, &dbase->llist) < 0)
+ goto err;
/* First cache any child dbase, which must
* be the first thing done when calling dbase
@@ -157,6 +160,7 @@ static int dbase_join_cache(
free(records2);
rtable->key_free(rkey);
rtable->free(record);
+ dbase_llist_drop_cache(&dbase->llist);
return STATUS_ERR;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-01-17 19:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-17 19:26 [SEMANAGE] Fix memory leak in cache error path Ivan Gyurdiev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.