Merge pull request #4088 from stapelberg/san

free(socket_path) to suppress leak sanitizer false-positive with -O2
This commit is contained in:
Orestis Floros 2020-05-18 18:25:19 +02:00 committed by GitHub
commit 7a4354f42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}