# HG changeset patch # User Paul Aurich # Date 1311228654 0 # Node ID b863432e81d1c8ff2db328aec67d7779ce5f6cd9 # Parent c571dbf696dac65ed7c5dffbfcb0e0e84ad07690 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. diff -r c571dbf696da -r b863432e81d1 libpurple/plugins/log_reader.c --- 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++; } }