[PATCH] addon-cpufreq: do not leak va_arg on error condition

Guillem Jover guillem.jover at nokia.com
Fri Feb 13 10:36:14 PST 2009


---
 hald/linux/addons/addon-cpufreq.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index 8f9567c..f8d29ab 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -127,6 +127,7 @@ gboolean write_line(const char *filename, const char *fmt, ...)
 {
 	va_list	ap;
 	FILE	*fp;
+	int	l;
 
 	fp = fopen(filename, "w+");
 	if (!fp) {
@@ -136,15 +137,16 @@ gboolean write_line(const char *filename, const char *fmt, ...)
 	}
 
 	va_start(ap, fmt);
+	l = vfprintf(fp, fmt, ap);
+	va_end(ap);
+
+	fclose(fp);
 
-	if (vfprintf(fp, fmt, ap) < 0) {
+	if (l < 0) {
 		HAL_WARNING(("Could not write to file: %s", filename));
-		fclose(fp);
 		return FALSE;
 	}
 
-	va_end(ap);
-	fclose(fp);
 	return TRUE;
 }
 
-- 
1.6.0.2



More information about the hal mailing list