From a9a09f147f725357ba321933cf2106b57ab52fc8 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sat, 15 Jul 2000 07:18:19 +0000 Subject: [PATCH] fixed an off by 0 error (yeah, the function went off when the while (n--) Sat Jul 15 09:11:46 2000 Tim Janik * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, the function went off when the while (n--) loop failed due to n==0 ;), reported by Jean-Louis HAMEL . --- ChangeLog | 6 ++++++ ChangeLog.pre-2-0 | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-12 | 6 ++++++ ChangeLog.pre-2-2 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ glib/gstrfuncs.c | 5 +++-- gstrfuncs.c | 5 +++-- 10 files changed, 54 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a4ad43..4b45062 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 6a4ad43..4b45062 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Sat Jul 15 09:11:46 2000 Tim Janik + + * gstrfuncs.c (g_strncasecmp): fixed an off by 0 error (yeah, + the function went off when the while (n--) loop failed due to + n==0 ;), reported by Jean-Louis HAMEL . + 2000-07-15 Tor Lillqvist * Makefile.am (SUBDIRS): Include the "build" module in GLib, too, diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index e4f633e..0bec543 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -908,8 +908,9 @@ g_strncasecmp (const gchar *s1, g_return_val_if_fail (s1 != NULL, 0); g_return_val_if_fail (s2 != NULL, 0); - while (n-- && *s1 && *s2) + while (n && *s1 && *s2) { + n -= 1; /* According to A. Cox, some platforms have islower's that * don't work right on non-uppercase */ @@ -921,7 +922,7 @@ g_strncasecmp (const gchar *s1, } if (n) - return (((gint)(guchar) *s1) - ((gint)(guchar) *s2)); + return (((gint) (guchar) *s1) - ((gint) (guchar) *s2)); else return 0; #endif diff --git a/gstrfuncs.c b/gstrfuncs.c index e4f633e..0bec543 100644 --- a/gstrfuncs.c +++ b/gstrfuncs.c @@ -908,8 +908,9 @@ g_strncasecmp (const gchar *s1, g_return_val_if_fail (s1 != NULL, 0); g_return_val_if_fail (s2 != NULL, 0); - while (n-- && *s1 && *s2) + while (n && *s1 && *s2) { + n -= 1; /* According to A. Cox, some platforms have islower's that * don't work right on non-uppercase */ @@ -921,7 +922,7 @@ g_strncasecmp (const gchar *s1, } if (n) - return (((gint)(guchar) *s1) - ((gint)(guchar) *s2)); + return (((gint) (guchar) *s1) - ((gint) (guchar) *s2)); else return 0; #endif -- 2.7.4