summaryrefslogtreecommitdiff
path: root/slstatus.c
diff options
context:
space:
mode:
authorAaron Marcher <info@nulltime.net>2016-03-17 19:15:17 +0100
committerAaron Marcher <info@nulltime.net>2016-03-17 19:15:17 +0100
commit096737778bdd57e41dcc5f2c2bae2e175f86435b (patch)
tree98a6839bccaca5bbbfdeb9049963cb7f02ad534f /slstatus.c
parentbc12a40dec3ddf8914df035349ea771d79ed56db (diff)
parent67f61b839e21c05f787ec8edf68946e0c1aed077 (diff)
Merge pull request #10 from sahne/master
Fix some memory leaks
Diffstat (limited to 'slstatus.c')
-rw-r--r--slstatus.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/slstatus.c b/slstatus.c
index 76df821..1db9af8 100644
--- a/slstatus.c
+++ b/slstatus.c
@@ -179,7 +179,9 @@ get_datetime(const char *timeformat)
setlocale(LC_TIME, "C");
/* return time */
- return smprintf("%s", buf);
+ char *ret = smprintf("%s", buf);
+ free(buf);
+ return ret;
}
/* disk usage percentage */
@@ -346,7 +348,7 @@ main()
/* return status every interval */
for (;;) {
/* clear the string */
- strcpy(status_string, "");
+ memset(status_string, 0, sizeof(status_string));
/* generate status_string */
for (size_t i = 0; i < sizeof(args) / sizeof(args[0]); ++i) {
@@ -354,6 +356,8 @@ main()
char *res = argument.func(argument.args);
char *element = smprintf(argument.format, res);
strcat(status_string, element);
+ free(res);
+ free(element);
}
/* return the statusbar */