71 lines
2.5 KiB
Diff
71 lines
2.5 KiB
Diff
From aaee2b3eaefcb42414d72cbcf656eae06c3adb75 Mon Sep 17 00:00:00 2001
|
|
From: Michael Stapelberg <michael@stapelberg.de>
|
|
Date: Mon, 2 Jan 2023 11:33:22 +0100
|
|
Subject: [PATCH 1/1] free some heap allocations to satisfy LeakSanitizer
|
|
|
|
---
|
|
src/main.c | 22 +++++++++++++++-------
|
|
1 file changed, 15 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/src/main.c b/src/main.c
|
|
index 6d6b9c9c..f679966f 100644
|
|
--- a/src/main.c
|
|
+++ b/src/main.c
|
|
@@ -1002,10 +1002,11 @@ int main(int argc, char *argv[]) {
|
|
char *log_stream_socket_path = get_process_filename("log-stream-socket");
|
|
int log_socket = create_socket(log_stream_socket_path, ¤t_log_stream_socket_path);
|
|
free(log_stream_socket_path);
|
|
+ struct ev_io *log_io = NULL;
|
|
if (log_socket == -1) {
|
|
ELOG("Could not create the log socket, i3-dump-log -f will not work\n");
|
|
} else {
|
|
- struct ev_io *log_io = scalloc(1, sizeof(struct ev_io));
|
|
+ log_io = scalloc(1, sizeof(struct ev_io));
|
|
ev_io_init(log_io, log_new_client, log_socket, EV_READ);
|
|
ev_io_start(main_loop, log_io);
|
|
}
|
|
@@ -1013,12 +1014,13 @@ int main(int argc, char *argv[]) {
|
|
/* Also handle the UNIX domain sockets passed via socket
|
|
* activation. The parameter 0 means "do not remove the
|
|
* environment variables", we need to be able to reexec. */
|
|
+ struct ev_io *socket_ipc_io = NULL;
|
|
listen_fds = sd_listen_fds(0);
|
|
- if (listen_fds < 0)
|
|
+ if (listen_fds < 0) {
|
|
ELOG("socket activation: Error in sd_listen_fds\n");
|
|
- else if (listen_fds == 0)
|
|
+ } else if (listen_fds == 0) {
|
|
DLOG("socket activation: no sockets passed\n");
|
|
- else {
|
|
+ } else {
|
|
int flags;
|
|
for (int fd = SD_LISTEN_FDS_START;
|
|
fd < (SD_LISTEN_FDS_START + listen_fds);
|
|
@@ -1033,9 +1035,9 @@ int main(int argc, char *argv[]) {
|
|
ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd);
|
|
}
|
|
|
|
- struct ev_io *ipc_io = scalloc(1, sizeof(struct ev_io));
|
|
- ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
|
|
- ev_io_start(main_loop, ipc_io);
|
|
+ socket_ipc_io = scalloc(1, sizeof(struct ev_io));
|
|
+ ev_io_init(socket_ipc_io, ipc_new_client, fd, EV_READ);
|
|
+ ev_io_start(main_loop, socket_ipc_io);
|
|
}
|
|
}
|
|
|
|
@@ -1198,4 +1200,10 @@ int main(int argc, char *argv[]) {
|
|
|
|
sd_notify(1, "READY=1");
|
|
ev_loop(main_loop, 0);
|
|
+
|
|
+ /* Free these heap allocations just to satisfy LeakSanitizer. */
|
|
+ FREE(ipc_io);
|
|
+ FREE(socket_ipc_io);
|
|
+ FREE(log_io);
|
|
+ FREE(xcb_watcher);
|
|
}
|
|
--
|
|
2.20.1
|
|
|