From 93d99f37126b93176677fb22cf7500d10f3db6e4 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 2 Dec 2016 18:57:10 -0500 Subject: [PATCH] Fix use-after-free --- sway/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/security.c b/sway/security.c index 0d5102532..1d236b1df 100644 --- a/sway/security.c +++ b/sway/security.c @@ -29,7 +29,6 @@ enum secure_feature get_feature_policy(pid_t pid) { FEATURE_FULLSCREEN | FEATURE_KEYBOARD | FEATURE_MOUSE; ssize_t len = readlink(path, link, sizeof(link)); - free(path); if (len < 0) { sway_log(L_INFO, "WARNING: unable to read %s for security check. Using default policy.", @@ -38,6 +37,7 @@ enum secure_feature get_feature_policy(pid_t pid) { } else { link[len] = '\0'; } + free(path); for (int i = 0; i < config->feature_policies->length; ++i) { struct feature_policy *policy = config->feature_policies->items[i];