summaryrefslogtreecommitdiff
path: root/gtk/gtkselection.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2007-07-09 20:24:26 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2007-07-09 20:24:26 +0000
commit5450603225779045e1dc04e8d5874d930a18a2b3 (patch)
tree5eb690f77e17451d16e32d515b636999edafb993 /gtk/gtkselection.c
parent4689dc3fd3973d03daa1c48a8be3c6c448fc6aa8 (diff)
downloadgtk+-5450603225779045e1dc04e8d5874d930a18a2b3.tar.gz
Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan)
2007-07-09 Matthias Clasen <mclasen@redhat.com> * gtk/gtkselection.c (normalize_to_crlf): Don't ignore the passed-in len parameter. (#430049, Yevgen Muntyan) svn path=/trunk/; revision=18423
Diffstat (limited to 'gtk/gtkselection.c')
-rw-r--r--gtk/gtkselection.c10
1 files changed, 5 insertions, 5 deletions
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++;
}