Mercurial > pidgin.yaz
changeset 25166:937d832f4d7f
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
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 26 Feb 2009 03:44:58 +0000 |
parents | da0ff574d2b4 |
children | fc615861c88c |
files | libpurple/protocols/oscar/oscar.c |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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';