aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-08-20 15:21:34 -0400
committerGitHub <noreply@github.com>2018-08-20 15:21:34 -0400
commit99631c505097cd5b7c13b5f89711e089435cb0da (patch)
treed65d814c54985e8d09f994b0b739e08a724952b2 /swaynag
parent881f729af9e675710dea43eb268cf644e6ec66be (diff)
parentf0d21c46dd8eedc186509cf0ed20833b746182e7 (diff)
Merge pull request #2501 from RedSoxFan/fix-bad-free-swaynag
Fix bad-free in swaynag
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/config.c4
-rw-r--r--swaynag/main.c15
2 files changed, 11 insertions, 8 deletions
diff --git a/swaynag/config.c b/swaynag/config.c
index d6c5739d..4d0824c9 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -180,8 +180,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
break;
case 'L': // Detailed Button Text
if (swaynag) {
- free(swaynag->details.button_details.text);
- swaynag->details.button_details.text = strdup(optarg);
+ free(swaynag->details.button_details->text);
+ swaynag->details.button_details->text = strdup(optarg);
}
break;
case 'm': // Message
diff --git a/swaynag/main.c b/swaynag/main.c
index 6b0b5236..d1a0d236 100644
--- a/swaynag/main.c
+++ b/swaynag/main.c
@@ -34,9 +34,10 @@ int main(int argc, char **argv) {
button_close->type = SWAYNAG_ACTION_DISMISS;
list_add(swaynag.buttons, button_close);
- swaynag.details.button_details.text = strdup("Toggle Details");
- swaynag.details.button_details.type = SWAYNAG_ACTION_EXPAND;
-
+ swaynag.details.button_details =
+ calloc(sizeof(struct swaynag_button), 1);
+ swaynag.details.button_details->text = strdup("Toggle Details");
+ swaynag.details.button_details->type = SWAYNAG_ACTION_EXPAND;
char *config_path = NULL;
bool debug = false;
@@ -99,9 +100,10 @@ int main(int argc, char **argv) {
swaynag_types_free(types);
if (swaynag.details.message) {
- list_add(swaynag.buttons, &swaynag.details.button_details);
+ list_add(swaynag.buttons, swaynag.details.button_details);
} else {
- free(swaynag.details.button_details.text);
+ free(swaynag.details.button_details->text);
+ free(swaynag.details.button_details);
}
wlr_log(WLR_DEBUG, "Output: %s", swaynag.type->output);
@@ -123,7 +125,8 @@ int main(int argc, char **argv) {
cleanup:
swaynag_types_free(types);
- free(swaynag.details.button_details.text);
+ free(swaynag.details.button_details->text);
+ free(swaynag.details.button_details);
swaynag_destroy(&swaynag);
return exit_code;
}