mirror of
https://github.com/swaywm/sway.git
synced 2024-12-28 07:56:31 +01:00
Fix bad-free in swaynag
This commit is contained in:
parent
881f729af9
commit
f0d21c46dd
3 changed files with 12 additions and 9 deletions
|
@ -58,7 +58,7 @@ struct swaynag_details {
|
||||||
int offset;
|
int offset;
|
||||||
int visible_lines;
|
int visible_lines;
|
||||||
int total_lines;
|
int total_lines;
|
||||||
struct swaynag_button button_details;
|
struct swaynag_button *button_details;
|
||||||
struct swaynag_button button_up;
|
struct swaynag_button button_up;
|
||||||
struct swaynag_button button_down;
|
struct swaynag_button button_down;
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,8 +180,8 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
|
||||||
break;
|
break;
|
||||||
case 'L': // Detailed Button Text
|
case 'L': // Detailed Button Text
|
||||||
if (swaynag) {
|
if (swaynag) {
|
||||||
free(swaynag->details.button_details.text);
|
free(swaynag->details.button_details->text);
|
||||||
swaynag->details.button_details.text = strdup(optarg);
|
swaynag->details.button_details->text = strdup(optarg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'm': // Message
|
case 'm': // Message
|
||||||
|
|
|
@ -34,9 +34,10 @@ int main(int argc, char **argv) {
|
||||||
button_close->type = SWAYNAG_ACTION_DISMISS;
|
button_close->type = SWAYNAG_ACTION_DISMISS;
|
||||||
list_add(swaynag.buttons, button_close);
|
list_add(swaynag.buttons, button_close);
|
||||||
|
|
||||||
swaynag.details.button_details.text = strdup("Toggle Details");
|
swaynag.details.button_details =
|
||||||
swaynag.details.button_details.type = SWAYNAG_ACTION_EXPAND;
|
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;
|
char *config_path = NULL;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
|
@ -99,9 +100,10 @@ int main(int argc, char **argv) {
|
||||||
swaynag_types_free(types);
|
swaynag_types_free(types);
|
||||||
|
|
||||||
if (swaynag.details.message) {
|
if (swaynag.details.message) {
|
||||||
list_add(swaynag.buttons, &swaynag.details.button_details);
|
list_add(swaynag.buttons, swaynag.details.button_details);
|
||||||
} else {
|
} 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);
|
wlr_log(WLR_DEBUG, "Output: %s", swaynag.type->output);
|
||||||
|
@ -123,7 +125,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
swaynag_types_free(types);
|
swaynag_types_free(types);
|
||||||
free(swaynag.details.button_details.text);
|
free(swaynag.details.button_details->text);
|
||||||
|
free(swaynag.details.button_details);
|
||||||
swaynag_destroy(&swaynag);
|
swaynag_destroy(&swaynag);
|
||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue