/pidgin/main: ef3d115642d7: Fix purple_stringref_new()
Richard Laager
rlaager at pidgin.im
Sun Jan 13 17:02:38 EST 2013
Changeset: ef3d115642d779c26ff3065472c01e91c6dc0a64
Author: Richard Laager <rlaager at pidgin.im>
Date: 2013-01-13 13:53 -0600
Branch: release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/ef3d115642d7
Description:
Fix purple_stringref_new()
It was losing the last character of the input string. This was
happening because g_strlcpy() takes the length of the buffer and we
were passing it strlen(value), which would not include the NUL.
This was breaking reading old logs.
diffstat:
libpurple/stringref.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diffs (14 lines):
diff --git a/libpurple/stringref.c b/libpurple/stringref.c
--- a/libpurple/stringref.c
+++ b/libpurple/stringref.c
@@ -73,7 +73,9 @@ PurpleStringref *purple_stringref_new(co
len = strlen(value);
newref = g_malloc(sizeof(PurpleStringref) + len);
- g_strlcpy(newref->value, value, len);
+ /* g_strlcpy() takes the size of the buffer, including the NUL.
+ strlen() returns the length of the string, without the NUL. */
+ g_strlcpy(newref->value, value, len + 1);
newref->ref = 1;
return newref;
More information about the Commits
mailing list