summary refs log tree commit diff stats
path: root/src/common/text.c
diff options
context:
space:
mode:
authorArnavion <arnavion@gmail.com>2012-11-03 21:32:52 -0700
committerArnavion <arnavion@gmail.com>2012-11-03 21:32:52 -0700
commitc2c23894fc4e376ff10c9c3cbcfa5c350c1e3073 (patch)
treecfcfb0f27d78dd65bb657f0e0caeabb42737cc03 /src/common/text.c
parent4ec499c2417819a174ebd68529da2a21e9c5c72c (diff)
utf8-everywhere: Fixed crash on loading scrollback.
Diffstat (limited to 'src/common/text.c')
-rw-r--r--src/common/text.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/common/text.c b/src/common/text.c
index 21ff2e55..44cdeff8 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -249,13 +249,13 @@ scrollback_save (session *sess, char *text)
 void
 scrollback_load (session *sess)
 {
-	int fh;
 	char *buf;
 	char *text;
 	time_t stamp;
 	int lines;
 	GIOChannel *io;
-	GError* io_err;
+	GError *file_error = NULL;
+	GError *io_err = NULL;
 
 #ifndef WIN32
 	char *map, *end_map;
@@ -277,22 +277,16 @@ scrollback_load (session *sess)
 	if ((buf = scrollback_get_filename (sess)) == NULL)
 		return;
 
-	fh = g_open (buf, O_RDONLY | OFLAGS, 0);
+	io = g_io_channel_new_file (buf, "r", &file_error);
 	g_free (buf);
-	if (fh == -1)
+	if (!io)
 		return;
 
-#ifndef WIN32
-	io = g_io_channel_unix_new (fh);
-#else
-	io = g_io_channel_win32_new_fd (fh);
-#endif
-
 	lines = 0;
 
 	while (1)
 	{
-		int n_bytes;
+		gsize n_bytes;
 		GIOStatus io_status;
 
 		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_shutdown (io, TRUE, NULL);
-	close (fh);
 
 	sess->scrollwritten = lines;