all repos — slstatus @ 67f61b839e21c05f787ec8edf68946e0c1aed077

my build of slstatus (tools.suckless.org/slstatus/)

Fix some memory leaks
Daniel Walter dwalter@sigma-star.at
Thu, 17 Mar 2016 19:12:47 +0100
commit

67f61b839e21c05f787ec8edf68946e0c1aed077

parent

bc12a40dec3ddf8914df035349ea771d79ed56db

1 files changed, 6 insertions(+), 2 deletions(-)

jump to
M slstatus.cslstatus.c

@@ -179,7 +179,9 @@ }

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 @@

/* 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 @@ argument = args[i];

char *res = argument.func(argument.args); char *element = smprintf(argument.format, res); strcat(status_string, element); + free(res); + free(element); } /* return the statusbar */