summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOrestis Floros <orestisflo@gmail.com>2020-05-01 10:04:33 +0200
committerOrestis Floros <orestisflo@gmail.com>2020-05-01 13:55:19 +0200
commit980164cccaa37eea7494b2d238fdb3e4c73e3beb (patch)
tree61b503f0fd72941aa76c6d83a2f7e88c3af912b0
parentef03d7c4794d35cf322288c93577ea777a17c697 (diff)
Fix various memory leaks
Fixes #362
-rw-r--r--i3status.c4
-rw-r--r--src/print_ddate.c1
-rw-r--r--src/print_run_watch.c2
-rw-r--r--src/print_time.c3
4 files changed, 9 insertions, 1 deletions
diff --git a/i3status.c b/i3status.c
index 464c641..bf2f1cd 100644
--- a/i3status.c
+++ b/i3status.c
@@ -207,6 +207,7 @@ static char *get_config_path(void) {
config_path = resolve_tilde("~/.i3status.conf");
if (path_exists(config_path))
return config_path;
+ free(config_path);
char *buf = strdup(xdg_config_dirs);
char *tok = strtok(buf, ":");
while (tok != NULL) {
@@ -230,7 +231,6 @@ static char *get_config_path(void) {
die("Unable to find the configuration file (looked at "
"~/.i3status.conf, $XDG_CONFIG_HOME/i3status/config, " SYSCONFDIR "/i3status.conf and $XDG_CONFIG_DIRS/i3status/config)");
- return NULL;
}
/*
@@ -807,4 +807,6 @@ int main(int argc, char *argv[]) {
struct timespec ts = {interval - 1 - (current_timeval.tv_sec % interval), (10e5 - current_timeval.tv_usec) * 1000};
nanosleep(&ts, NULL);
}
+
+ yajl_gen_free(json_gen);
}
diff --git a/src/print_ddate.c b/src/print_ddate.c
index 1a5258c..149a267 100644
--- a/src/print_ddate.c
+++ b/src/print_ddate.c
@@ -173,4 +173,5 @@ void print_ddate(yajl_gen json_gen, char *buffer, const char *format, time_t t)
const size_t num = sizeof(placeholders) / sizeof(placeholder_t);
buffer = format_placeholders(format, &placeholders[0], num);
OUTPUT_FULL_TEXT(buffer);
+ free(buffer);
}
diff --git a/src/print_run_watch.c b/src/print_run_watch.c
index d153da4..ccc7206 100644
--- a/src/print_run_watch.c
+++ b/src/print_run_watch.c
@@ -1,6 +1,7 @@
// vim:ts=4:sw=4:expandtab
#include <config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
@@ -35,4 +36,5 @@ void print_run_watch(yajl_gen json_gen, char *buffer, const char *title, const c
END_COLOR;
OUTPUT_FULL_TEXT(buffer);
+ free(buffer);
}
diff --git a/src/print_time.c b/src/print_time.c
index 67930b7..eede31d 100644
--- a/src/print_time.c
+++ b/src/print_time.c
@@ -82,4 +82,7 @@ void print_time(yajl_gen json_gen, char *buffer, const char *title, const char *
out:
*outwalk = '\0';
OUTPUT_FULL_TEXT(buffer);
+ if (format_time != NULL) {
+ free(buffer);
+ }
}