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

Commit

Permalink
free(socket_path) to suppress leak sanitizer false-positive with -O2
Browse files Browse the repository at this point in the history
related to #4086 (triggered by our meson config)
related to #4087 (sanitizer cleanup tracking bug)
  • Loading branch information
stapelberg committed May 18, 2020
1 parent 08052dd commit ed0d6ac
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.c
Expand Up @@ -376,6 +376,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 ed0d6ac

Please sign in to comment.