Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4088 from stapelberg/san
Browse files Browse the repository at this point in the history
free(socket_path) to suppress leak sanitizer false-positive with -O2
  • Loading branch information
orestisfl committed May 18, 2020
2 parents f233245 + ed0d6ac commit 7a4354f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.c
Expand Up @@ -380,6 +380,11 @@ int main(int argc, char *argv[]) {
char *socket_path = root_atom_contents("I3_SOCKET_PATH", NULL, 0);
if (socket_path) {
printf("%s\n", socket_path);
/* With -O2 (i.e. the buildtype=debugoptimized meson
* option, which we set by default), gcc 9.2.1 optimizes
* away socket_path at this point, resulting in a Leak
* Sanitizer report. An explicit free helps: */
free(socket_path);
exit(EXIT_SUCCESS);
}

Expand Down

0 comments on commit 7a4354f

Please sign in to comment.