(str_nconvert_to_input): return NULL if input is NULL.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2023-05-21 13:07:23 +03:00
parent 464a2eeefc
commit 0869946de5
5 changed files with 25 additions and 11 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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