1
0
mirror of https://github.com/moparisthebest/hexchat synced 2024-08-13 16:53:48 -04:00

utf8-everywhere: Fixed crash on loading scrollback.

This commit is contained in:
Arnavion 2012-11-03 21:32:52 -07:00
parent 4ec499c241
commit c2c23894fc

View File

@ -249,13 +249,13 @@ scrollback_save (session *sess, char *text)
void void
scrollback_load (session *sess) scrollback_load (session *sess)
{ {
int fh;
char *buf; char *buf;
char *text; char *text;
time_t stamp; time_t stamp;
int lines; int lines;
GIOChannel *io; GIOChannel *io;
GError* io_err; GError *file_error = NULL;
GError *io_err = NULL;
#ifndef WIN32 #ifndef WIN32
char *map, *end_map; char *map, *end_map;
@ -277,22 +277,16 @@ scrollback_load (session *sess)
if ((buf = scrollback_get_filename (sess)) == NULL) if ((buf = scrollback_get_filename (sess)) == NULL)
return; return;
fh = g_open (buf, O_RDONLY | OFLAGS, 0); io = g_io_channel_new_file (buf, "r", &file_error);
g_free (buf); g_free (buf);
if (fh == -1) if (!io)
return; return;
#ifndef WIN32
io = g_io_channel_unix_new (fh);
#else
io = g_io_channel_win32_new_fd (fh);
#endif
lines = 0; lines = 0;
while (1) while (1)
{ {
int n_bytes; gsize n_bytes;
GIOStatus io_status; GIOStatus io_status;
io_status = g_io_channel_read_line (io, &buf, &n_bytes, NULL, &io_err); io_status = g_io_channel_read_line (io, &buf, &n_bytes, NULL, &io_err);
@ -350,8 +344,6 @@ scrollback_load (session *sess)
} }
g_io_channel_unref (io); g_io_channel_unref (io);
g_io_channel_shutdown (io, TRUE, NULL);
close (fh);
sess->scrollwritten = lines; sess->scrollwritten = lines;