[babl] babl: fix memory leaks on error paths
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [babl] babl: fix memory leaks on error paths
- Date: Sat, 11 Nov 2017 13:08:27 +0000 (UTC)
commit 23def34b96fb69cfe9ca3c8e8cee7c01383779ff
Author: Tobias Stoeckmann <tobias stoeckmann org>
Date: Fri Oct 13 18:32:52 2017 +0200
babl: fix memory leaks on error paths
The database-focused functions of babl-cache are prone to
memory leaks when errors occur.
Signed-off-by: Tobias Stoeckmann <tobias stoeckmann org>
babl/babl-cache.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index 13badc5..dcc76f4 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -170,10 +170,15 @@ void babl_store_db (void)
char *tmpp = calloc(8000,1);
FILE *dbfile;
+ if (!tmpp)
+ return;
snprintf (tmpp, 8000, "%s~", fish_cache_path ());
dbfile = fopen (tmpp, "w");
if (!dbfile)
+ {
+ free (tmpp);
return;
+ }
fprintf (dbfile, "%s\n", cache_header ());
/* sort the list of fishes by usage, making next run more efficient -
@@ -273,6 +278,7 @@ void babl_init_db (void)
{
fprintf (stderr, "%s:%i: loading of cache failed\n",
__FUNCTION__, __LINE__);
+ free (contents);
return;
}
@@ -315,6 +321,7 @@ void babl_init_db (void)
Babl *conv = (void*)babl_db_find(babl_conversion_db(), &token[1]);
if (!conv)
{
+ free (contents);
return;
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]