[geany/geany] 5356c4: Fix infinite loop on OS X when using find in files

Jiří Techet git-noreply at xxxxx
Tue Feb 10 16:23:24 UTC 2015


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Tue, 20 Jan 2015 18:33:06 UTC
Commit:      5356c4549ace052b2e3be5451c9c6410ab3d9e41
             https://github.com/geany/geany/commit/5356c4549ace052b2e3be5451c9c6410ab3d9e41

Log Message:
-----------
Fix infinite loop on OS X when using find in files

The GIOCondition is always set to G_IO_IN even when input end
is reached (and no other flags are set) so the read_fif_io()
function never returns FALSE which causes an infinite loop.
It is necessary to check also the return value of
g_io_channel_read_line() and return FALSE on EOF or error.


Modified Paths:
--------------
    src/search.c

Modified: src/search.c
6 lines changed, 5 insertions(+), 1 deletions(-)
===================================================================
@@ -1841,8 +1841,10 @@ static gboolean read_fif_io(GIOChannel *source, GIOCondition condition, gchar *e
 	if (condition & (G_IO_IN | G_IO_PRI))
 	{
 		gchar *msg, *utf8_msg;
+		GIOStatus st;
 
-		while (g_io_channel_read_line(source, &msg, NULL, NULL, NULL) && msg)
+		while ((st = g_io_channel_read_line(source, &msg, NULL, NULL, NULL)) != G_IO_STATUS_ERROR &&
+				st != G_IO_STATUS_EOF && msg)
 		{
 			utf8_msg = NULL;
 
@@ -1866,6 +1868,8 @@ static gboolean read_fif_io(GIOChannel *source, GIOCondition condition, gchar *e
 				g_free(utf8_msg);
 			g_free(msg);
 		}
+		if (st == G_IO_STATUS_ERROR || st == G_IO_STATUS_EOF)
+			return FALSE;
 	}
 	if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
 		return FALSE;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list