From 534ae453038e2ee343c3ec924f1c6093f2ea7bf6 Mon Sep 17 00:00:00 2001 From: Maxime Villard Date: Sat, 15 Dec 2012 14:29:38 +0000 Subject: [PATCH] From: Maxime Villard Subject: Re: [E-devel] [e] [patch] Leak (was FreeBSD patch) I would also move some {free(x); x = null} to E_FREE. SVN revision: 81023 --- src/modules/temperature/tempget.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/modules/temperature/tempget.c b/src/modules/temperature/tempget.c index 7bad3d97f..6d614a178 100644 --- a/src/modules/temperature/tempget.c +++ b/src/modules/temperature/tempget.c @@ -426,7 +426,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3) ret = 1; else @@ -444,7 +443,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; if (sscanf(buf, "%i", &temp) == 1) ret = 1; else @@ -463,7 +461,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; /* actually read the temp */ if (sscanf(buf, "%i", &temp) == 1) ret = 1; @@ -483,7 +480,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; /* actually read the temp */ if (sscanf(buf, "%i", &temp) == 1) ret = 1; @@ -505,7 +501,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; p = strchr(buf, ':'); if (p) { @@ -531,7 +526,6 @@ check(void) if (fgets(buf, sizeof(buf), f) == NULL) goto error; fclose(f); f = NULL; - buf[sizeof(buf) - 1] = 0; temp = atoi(buf); temp /= 1000; ret = 1; @@ -549,12 +543,9 @@ check(void) return -999; error: if (f) fclose(f); - f = NULL; sensor_type = SENSOR_TYPE_NONE; - if (sensor_name) free(sensor_name); - sensor_name = NULL; - if (sensor_path) free(sensor_path); - sensor_path = NULL; + E_FREE(sensor_name); + E_FREE(sensor_path); return -999; }