41 lines
1.0 KiB
Diff
41 lines
1.0 KiB
Diff
From 4e4fd6a5fc84b8dc172e1ea67b28064c67376d1a Mon Sep 17 00:00:00 2001
|
|
From: Maks Mishin <maks.mishinFZ@gmail.com>
|
|
Date: Thu, 17 Oct 2024 07:14:26 +0300
|
|
Subject: [PATCH] sys-utils: (save_adjtime): fix memory leak
|
|
|
|
Dynamic memory, referenced by 'content', is allocated by calling function 'xasprintf'
|
|
and lost when function returns.
|
|
|
|
Found by the static analyzer Svace.
|
|
---
|
|
sys-utils/hwclock.c | 3 +++
|
|
1 file changed, 3 insertions(+)
|
|
|
|
diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
|
|
index 87228b5..1318c13 100644
|
|
--- a/sys-utils/hwclock.c
|
|
+++ b/sys-utils/hwclock.c
|
|
@@ -910,6 +910,7 @@ static int save_adjtime(const struct hwclock_control *ctl,
|
|
fp = fopen(ctl->adj_file_name, "w");
|
|
if (fp == NULL) {
|
|
warn(_("cannot open %s"), ctl->adj_file_name);
|
|
+ free(content);
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
@@ -918,9 +919,11 @@ static int save_adjtime(const struct hwclock_control *ctl,
|
|
|
|
if (rc) {
|
|
warn(_("cannot update %s"), ctl->adj_file_name);
|
|
+ free(content);
|
|
return EXIT_FAILURE;
|
|
}
|
|
}
|
|
+ free(content);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|
|
--
|
|
2.43.0
|
|
|