---
 dwmstatus-temperature.c | 6 +++++-
 dwmstatus.c             | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dwmstatus-temperature.c b/dwmstatus-temperature.c
index 13f27f6..793c723 100644
--- a/dwmstatus-temperature.c
+++ b/dwmstatus-temperature.c
@@ -6,10 +6,14 @@ char *
 gettemperature(char *base, char *sensor)
 {
        char *co;
+       float t;
 
        co = readfile(base, sensor);
        if (co == NULL)
                return smprintf("");
-       return smprintf("%02.0f°C", atof(co) / 1000);
+       t = atof(co);
+       free(co);
+
+       return smprintf("%02.0f°C", t / 1000);
 }
 
diff --git a/dwmstatus.c b/dwmstatus.c
index d2a4b03..9e2fd7e 100644
--- a/dwmstatus.c
+++ b/dwmstatus.c
@@ -168,11 +168,15 @@ char *
 gettemperature(char *base, char *sensor)
 {
        char *co;
+       float t;
 
        co = readfile(base, sensor);
        if (co == NULL)
                return smprintf("");
-       return smprintf("%02.0f°C", atof(co) / 1000);
+       t = atof(co);
+       free(co);
+
+       return smprintf("%02.0f°C", t / 1000);
 }
 
 int
-- 
2.27.0


Reply via email to