From 5450603225779045e1dc04e8d5874d930a18a2b3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 9 Jul 2007 20:24:26 +0000 Subject: Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan) 2007-07-09 Matthias Clasen * gtk/gtkselection.c (normalize_to_crlf): Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan) svn path=/trunk/; revision=18423 --- gtk/gtkselection.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gtk/gtkselection.c') diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index b76090be20..16eb1c802d 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -1197,8 +1197,9 @@ normalize_to_crlf (const gchar *str, { GString *result = g_string_sized_new (len); const gchar *p = str; + const gchar *end = str + len; - while (1) + while (p < end) { if (*p == '\n') g_string_append_c (result, '\r'); @@ -1207,13 +1208,12 @@ normalize_to_crlf (const gchar *str, { g_string_append_c (result, *p); p++; - if (*p != '\n') + if (p == end || *p != '\n') g_string_append_c (result, '\n'); + if (p == end) + break; } - if (*p == '\0') - break; - g_string_append_c (result, *p); p++; } -- cgit v1.2.1