# HG changeset patch # User Mark Doliner # Date 1235619898 0 # Node ID 937d832f4d7f4f8f82bbce6fcb71a16ea2c7f4a5 # Parent da0ff574d2b4db959830e0e368d4d2e9c8a4ec71 Shaun Lindsay at Meebo tracked down a bug where this function reads past the end of the string if the input parameter ends in a space diff -r da0ff574d2b4 -r 937d832f4d7f libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Wed Feb 25 23:48:26 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Thu Feb 26 03:44:58 2009 +0000 @@ -6818,11 +6818,13 @@ g_return_val_if_fail(str != NULL, NULL); /* copy str to buf and skip all blanks */ - for (i=0, j=0; str[j] && i < BUF_LEN - 1; i++, j++) - { - while (str[j] == ' ') - j++; - buf[i] = str[j]; + i = 0; + for (j = 0; str[j]; j++) { + if (str[j] != ' ') { + buf[i++] = str[j]; + if (i >= BUF_LEN - 1) + break; + } } buf[i] = '\0';