changeset 32215:b863432e81d1

log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then) Woah, are my eyes bleary from staring at this code.
author Paul Aurich <paul@darkrain42.org>
date Thu, 21 Jul 2011 06:10:54 +0000
parents c571dbf696da
children 747c5be08e81
files libpurple/plugins/log_reader.c
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/plugins/log_reader.c	Thu Jul 21 05:55:03 2011 +0000
+++ b/libpurple/plugins/log_reader.c	Thu Jul 21 06:10:54 2011 +0000
@@ -1454,8 +1454,13 @@
 		const char *footer = NULL;
 		GString *temp = NULL;
 
-		/* The data is always terminated with a newline (see above) */
+		/* There's always a trailing '\n' at the end of the file (see above), so
+		 * just quit out if we don't find another, because we're at the end.
+		 */
 		c = strchr(c, '\n');
+		if (!c)
+			break;
+
 		*c = '\0';
 		c++;
 
@@ -1818,7 +1823,7 @@
 
 		gboolean add_new_log = FALSE;
 
-		if (*c) {
+		if (c && *c) {
 			if (purple_str_has_prefix(c, QIP_LOG_IN_MESSAGE) ||
 				purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) {
 
@@ -1903,8 +1908,8 @@
 
 		if (c && *c) {
 			/* find EOF */
-			c = strchr(c, '\n');
-			c++;
+			if ((c = strchr(c, '\n')))
+				c++;
 		}
 	}