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:
Fernando Tarlá Cardoso Lemos 2011-11-06 20:03:47 -02:00 committed by Michael Stapelberg
parent d5613905c8
commit af335f0403
1 changed files with 5 additions and 2 deletions

View File

@ -41,7 +41,7 @@ static xcb_pixmap_t pixmap;
static xcb_gcontext_t pixmap_gc;
static xcb_rectangle_t rect = { 0, 0, 600, 20 };
static i3Font font;
static char *prompt = "Please do not run this program.";
static char *prompt;
static button_t *buttons;
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[]) {
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;
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";
prompt = strdup("Please do not run this program.");
while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
switch (o) {
case 'v':
@ -246,6 +248,7 @@ int main(int argc, char *argv[]) {
pattern = strdup(optarg);
break;
case 'm':
FREE(prompt);
prompt = strdup(optarg);
break;
case 't':