Try to fix crasher on mixing glib free and free.

This commit is contained in:
Dave Davenport 2015-11-15 13:12:43 +01:00
parent 2eaffceada
commit 238a34162a
3 changed files with 36 additions and 30 deletions

View File

@ -217,13 +217,19 @@ static void dmenu_mode_free ( Switcher *sw )
return;
}
DmenuModePrivateData *pd = (DmenuModePrivateData *) sw->private_data;
if ( pd != NULL ) {
for ( size_t i = 0; i < pd->cmd_list_length; i++ ) {
if ( pd->cmd_list[i] ) {
free ( pd->cmd_list[i] );
}
}
g_free ( pd->cmd_list );
g_free ( pd->urgent_list );
g_free ( pd->active_list );
g_strfreev ( pd->cmd_list );
g_free ( pd->urgent_list );
g_free ( pd->active_list );
g_free ( pd );
sw->private_data = NULL;
g_free ( pd );
sw->private_data = NULL;
}
}
static void dmenu_mode_init ( Switcher *sw )
@ -399,15 +405,15 @@ int dmenu_switcher_dialog ( void )
void print_dmenu_options ( void )
{
int is_term = isatty ( fileno ( stdout ) );
print_help_msg ( "-mesg","[string]", "Print a small user message under the prompt (uses pango markup)", NULL, is_term );
print_help_msg ( "-p","[string]", "Prompt to display left of entry field", NULL, is_term );
print_help_msg ( "-selected-row","[integer]", "Select row", NULL, is_term );
print_help_msg ( "-format","[string]", "Output format string", "s", is_term );
print_help_msg ( "-u","[list]", "List of row indexes to mark urgent", NULL, is_term );
print_help_msg ( "-a","[list]", "List of row indexes to mark active", NULL, is_term );
print_help_msg ( "-l","[integer] ", "Number of rows to display", NULL, is_term );
print_help_msg ( "-i","", "Set filter to be case insensitive", NULL, is_term );
print_help_msg ( "-only-match","", "Force selection or custom entry", NULL, is_term );
print_help_msg ( "-no-custom","", "Don't accept custom entry", NULL, is_term );
print_help_msg ( "-select","[string]", "Select the first row that matches", NULL, is_term );
print_help_msg ( "-mesg", "[string]", "Print a small user message under the prompt (uses pango markup)", NULL, is_term );
print_help_msg ( "-p", "[string]", "Prompt to display left of entry field", NULL, is_term );
print_help_msg ( "-selected-row", "[integer]", "Select row", NULL, is_term );
print_help_msg ( "-format", "[string]", "Output format string", "s", is_term );
print_help_msg ( "-u", "[list]", "List of row indexes to mark urgent", NULL, is_term );
print_help_msg ( "-a", "[list]", "List of row indexes to mark active", NULL, is_term );
print_help_msg ( "-l", "[integer] ", "Number of rows to display", NULL, is_term );
print_help_msg ( "-i", "", "Set filter to be case insensitive", NULL, is_term );
print_help_msg ( "-only-match", "", "Force selection or custom entry", NULL, is_term );
print_help_msg ( "-no-custom", "", "Don't accept custom entry", NULL, is_term );
print_help_msg ( "-select", "[string]", "Select the first row that matches", NULL, is_term );
}

View File

@ -1834,16 +1834,16 @@ static void handle_keypress ( XEvent *ev )
static void print_main_application_options ( void )
{
int is_term = isatty ( fileno ( stdout ) );
print_help_msg ( "-no-config","", "Do not load configuration, use default values.", NULL, is_term );
print_help_msg ( "-quiet","", "Suppress information messages.", NULL, is_term );
print_help_msg ( "-v,-version","", "Print the version number and exit.", NULL, is_term );
print_help_msg ( "-dmenu","", "Start in dmenu mode.", NULL, is_term );
print_help_msg ( "-display","[string]", "X server to contact.", "${DISPLAY}", is_term );
print_help_msg ( "-h,-help","", "This help message.", NULL, is_term );
print_help_msg ( "-dump-xresources","", "Dump the current configuration in Xresources format and exit.", NULL, is_term );
print_help_msg ( "-e","[string]", "Show a dialog displaying the passed message and exit.", NULL, is_term );
print_help_msg ( "-markup", "","Enable pango markup where possible.", NULL, is_term );
print_help_msg ( "-normal-window","", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term );
print_help_msg ( "-no-config", "", "Do not load configuration, use default values.", NULL, is_term );
print_help_msg ( "-quiet", "", "Suppress information messages.", NULL, is_term );
print_help_msg ( "-v,-version", "", "Print the version number and exit.", NULL, is_term );
print_help_msg ( "-dmenu", "", "Start in dmenu mode.", NULL, is_term );
print_help_msg ( "-display", "[string]", "X server to contact.", "${DISPLAY}", is_term );
print_help_msg ( "-h,-help", "", "This help message.", NULL, is_term );
print_help_msg ( "-dump-xresources", "", "Dump the current configuration in Xresources format and exit.", NULL, is_term );
print_help_msg ( "-e", "[string]", "Show a dialog displaying the passed message and exit.", NULL, is_term );
print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term );
print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term );
print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term );
}
static void help ( G_GNUC_UNUSED int argc, char **argv )

View File

@ -495,15 +495,15 @@ void print_options ( void )
void print_help_msg ( const char *option, const char *type, const char*text, const char *def, int isatty )
{
int l = 37 - strlen ( option )-strlen(type);
int l = 37 - strlen ( option ) - strlen ( type );
if ( isatty ) {
printf ( "\t%s%s%s %s %-*c%s\n", color_bold, option, color_reset,type, l, ' ', text );
printf ( "\t%s%s%s %s %-*c%s\n", color_bold, option, color_reset, type, l, ' ', text );
if ( def != NULL ) {
printf ( "\t\t%s%s%s\n", color_italic, def, color_reset );
}
}
else{
printf ( "\t%s %s %-*c%s\n", option, type,l, ' ', text );
printf ( "\t%s %s %-*c%s\n", option, type, l, ' ', text );
if ( def != NULL ) {
printf ( "\t\t%s\n", def );
}