diff --git a/lib/charsets.c b/lib/charsets.c index 376de5f48..c97a3cf72 100644 --- a/lib/charsets.c +++ b/lib/charsets.c @@ -390,7 +390,7 @@ str_nconvert_to_input (const char *str, int len) GIConv conv; if (str == NULL) - return g_string_new (""); + return NULL; if (cp_display == cp_source) return g_string_new (str); diff --git a/src/diffviewer/search.c b/src/diffviewer/search.c index 80480ccc1..77d09cd17 100644 --- a/src/diffviewer/search.c +++ b/src/diffviewer/search.c @@ -127,7 +127,10 @@ mcdiffview_dialog_search (WDiff * dview) tmp = str_convert_to_input (exp); g_free (exp); - exp = g_string_free (tmp, FALSE); + if (tmp != NULL) + exp = g_string_free (tmp, FALSE); + else + exp = g_strdup (""); } #endif diff --git a/src/editor/editcomplete.c b/src/editor/editcomplete.c index f30c07b5a..06f304dc0 100644 --- a/src/editor/editcomplete.c +++ b/src/editor/editcomplete.c @@ -327,10 +327,12 @@ edit_complete_word_insert_recoded_completion (WEdit * edit, char *completion, gs GString *temp; temp = str_convert_to_input (completion); - - for (completion = temp->str + word_len; *completion != '\0'; completion++) - edit_insert (edit, *completion); - g_string_free (temp, TRUE); + if (temp != NULL) + { + for (completion = temp->str + word_len; *completion != '\0'; completion++) + edit_insert (edit, *completion); + g_string_free (temp, TRUE); + } #else for (completion += word_len; *completion != '\0'; completion++) edit_insert (edit, *completion); diff --git a/src/editor/editsearch.c b/src/editor/editsearch.c index 420173b81..1bdf88350 100644 --- a/src/editor/editsearch.c +++ b/src/editor/editsearch.c @@ -136,7 +136,10 @@ edit_dialog_search_show (WEdit * edit) tmp = str_convert_to_input (search_text); g_free (search_text); - search_text = g_string_free (tmp, FALSE); + if (tmp != NULL) + search_text = g_string_free (tmp, FALSE); + else + search_text = g_strdup (""); } #endif @@ -556,9 +559,12 @@ edit_replace_cmd__conv_to_input (char *str) GString *tmp; tmp = str_convert_to_input (str); - if (tmp->len != 0) - return g_string_free (tmp, FALSE); - g_string_free (tmp, TRUE); + if (tmp != NULL) + { + if (tmp->len != 0) + return g_string_free (tmp, FALSE); + g_string_free (tmp, TRUE); + } #endif return g_strdup (str); } diff --git a/src/viewer/dialogs.c b/src/viewer/dialogs.c index 0af797327..f15c2ff7b 100644 --- a/src/viewer/dialogs.c +++ b/src/viewer/dialogs.c @@ -122,7 +122,10 @@ mcview_dialog_search (WView * view) tmp = str_convert_to_input (exp); g_free (exp); - exp = g_string_free (tmp, FALSE); + if (tmp != NULL) + exp = g_string_free (tmp, FALSE); + else + exp = g_strdup (""); } #endif