comparison libpurple/plugins/log_reader.c @ 31757: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 6d6056e176fe
children 61ce89013291 3828a61c44da
comparison
equal deleted inserted replaced
31756:c571dbf696da 31757:b863432e81d1
1452 { 1452 {
1453 const char *link; 1453 const char *link;
1454 const char *footer = NULL; 1454 const char *footer = NULL;
1455 GString *temp = NULL; 1455 GString *temp = NULL;
1456 1456
1457 /* The data is always terminated with a newline (see above) */ 1457 /* There's always a trailing '\n' at the end of the file (see above), so
1458 * just quit out if we don't find another, because we're at the end.
1459 */
1458 c = strchr(c, '\n'); 1460 c = strchr(c, '\n');
1461 if (!c)
1462 break;
1463
1459 *c = '\0'; 1464 *c = '\0';
1460 c++; 1465 c++;
1461 1466
1462 /* Convert links. 1467 /* Convert links.
1463 * 1468 *
1816 start_log = contents; 1821 start_log = contents;
1817 while (main_cycle) { 1822 while (main_cycle) {
1818 1823
1819 gboolean add_new_log = FALSE; 1824 gboolean add_new_log = FALSE;
1820 1825
1821 if (*c) { 1826 if (c && *c) {
1822 if (purple_str_has_prefix(c, QIP_LOG_IN_MESSAGE) || 1827 if (purple_str_has_prefix(c, QIP_LOG_IN_MESSAGE) ||
1823 purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) { 1828 purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) {
1824 1829
1825 char *tmp; 1830 char *tmp;
1826 1831
1901 start_log = new_line; 1906 start_log = new_line;
1902 } 1907 }
1903 1908
1904 if (c && *c) { 1909 if (c && *c) {
1905 /* find EOF */ 1910 /* find EOF */
1906 c = strchr(c, '\n'); 1911 if ((c = strchr(c, '\n')))
1907 c++; 1912 c++;
1908 } 1913 }
1909 } 1914 }
1910 1915
1911 g_free(contents); 1916 g_free(contents);
1912 g_free(path); 1917 g_free(path);