summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem.jover@nokia.com>2009-02-21 11:40:38 +0100
committerDanny Kukawka <danny.kukawka@web.de>2009-02-21 11:40:38 +0100
commit0b50c9561267f78ce7af24eaee690e0b4dffb0eb (patch)
tree0728b065cba97490b6e1d12aa933a0b434660e04
parentaa50b81fe08101679ed4e905f5f8b490643b2661 (diff)
addon-cpufreq: do not leak va_arg on error condition
Fixed addon-cpufreq: do not leak va_arg on error condition.
-rw-r--r--hald/linux/addons/addon-cpufreq.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index 8f9567cb..f8d29abb 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;
}