Don't call free on statically allocated strings.
Fixes segfault when the option -f is used. Also, don't leak prompt strings. We either keep FREE to prevent leaking, or choose to leak and avoid strdup. Another option would be using a flag to indicate whether or not the strings are heap allocated, but it's overkill.
This commit is contained in:
parent
d5613905c8
commit
af335f0403
|
@ -41,7 +41,7 @@ static xcb_pixmap_t pixmap;
|
||||||
static xcb_gcontext_t pixmap_gc;
|
static xcb_gcontext_t pixmap_gc;
|
||||||
static xcb_rectangle_t rect = { 0, 0, 600, 20 };
|
static xcb_rectangle_t rect = { 0, 0, 600, 20 };
|
||||||
static i3Font font;
|
static i3Font font;
|
||||||
static char *prompt = "Please do not run this program.";
|
static char *prompt;
|
||||||
static button_t *buttons;
|
static button_t *buttons;
|
||||||
static int buttoncnt;
|
static int buttoncnt;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static int handle_expose(xcb_connection_t *conn, xcb_expose_event_t *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *pattern = "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
|
char *pattern = strdup("-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1");
|
||||||
int o, option_index = 0;
|
int o, option_index = 0;
|
||||||
enum { TYPE_ERROR = 0, TYPE_WARNING = 1 } bar_type = TYPE_ERROR;
|
enum { TYPE_ERROR = 0, TYPE_WARNING = 1 } bar_type = TYPE_ERROR;
|
||||||
|
|
||||||
|
@ -236,6 +236,8 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
char *options_string = "b:f:m:t:vh";
|
char *options_string = "b:f:m:t:vh";
|
||||||
|
|
||||||
|
prompt = strdup("Please do not run this program.");
|
||||||
|
|
||||||
while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
|
while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case 'v':
|
case 'v':
|
||||||
|
@ -246,6 +248,7 @@ int main(int argc, char *argv[]) {
|
||||||
pattern = strdup(optarg);
|
pattern = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
|
FREE(prompt);
|
||||||
prompt = strdup(optarg);
|
prompt = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
|
|
Loading…
Reference in New Issue