Kaydet (Commit) 50e6868c authored tarafından Enrico Tröger's avatar Enrico Tröger

Fix crash when trying to change the encoding of a file (introduced in r2529).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2535 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst b690b256
......@@ -15,6 +15,9 @@
* autogen.sh:
Don't check for CVS directory as we don't use CVS anymore and remove
non-portable -path option of find.
* src/document.c:
Fix crash when trying to change the encoding of a file
(introduced in r2529).
2008-04-25 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
......
......@@ -1315,18 +1315,18 @@ gboolean document_save_file_as(gint idx)
}
static gsize save_convert_to_encoding(gint idx, gchar *data, gsize *len)
static gsize save_convert_to_encoding(gint idx, gchar **data, gsize *len)
{
GError *conv_error = NULL;
gchar* conv_file_contents = NULL;
gsize bytes_read;
gsize conv_len;
g_return_val_if_fail(data != NULL, FALSE);
g_return_val_if_fail(data != NULL || *data == NULL, FALSE);
g_return_val_if_fail(len != NULL, FALSE);
/* try to convert it from UTF-8 to original encoding */
conv_file_contents = g_convert(data, *len - 1, doc_list[idx].encoding, "UTF-8",
conv_file_contents = g_convert(*data, *len - 1, doc_list[idx].encoding, "UTF-8",
&bytes_read, &conv_len, &conv_error);
if (conv_error != NULL)
......@@ -1370,8 +1370,8 @@ _("An error occurred while converting the file from UTF-8 in \"%s\". The file re
}
else
{
g_free(data);
data = conv_file_contents;
g_free(*data);
*data = conv_file_contents;
*len = conv_len;
}
......@@ -1469,7 +1469,7 @@ gboolean document_save_file(gint idx, gboolean force)
if (doc_list[idx].encoding != NULL && ! utils_str_equal(doc_list[idx].encoding, "UTF-8") &&
! utils_str_equal(doc_list[idx].encoding, encodings[GEANY_ENCODING_NONE].charset))
{
if (! save_convert_to_encoding(idx, data, &len))
if (! save_convert_to_encoding(idx, &data, &len))
{
g_free(data);
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment