summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2006-09-19 22:10:00 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2006-09-19 22:10:00 +0000
commitd389437b875a46fdc136e11b81a781d04380d518 (patch)
treeb8abf640b1f49f32ad2e62f16caabe5998771241
parent439de080e210d17c3809e096cbe8b3ac5ab21144 (diff)
Add check for end of string in all places after incrementing the current char
-rw-r--r--common/glib-ectomy.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c
index 56357648..83a2bb7b 100644
--- a/common/glib-ectomy.c
+++ b/common/glib-ectomy.c
@@ -532,11 +532,11 @@ gint g_timeout_remove(const guint id)
(val) |= (c) & 0x3f; \
} while (0)
-#define INCREMENT_AND_CHECK_MAX(i, max_len) \
- do { \
- (i)++; \
- if ((max_len) >= 0 && (i) >= (max_len)) \
- goto failed; \
+#define INCREMENT_AND_CHECK_MAX(p, i, max_len) \
+ do { \
+ (i)++; \
+ if ((p)[(i)] == '\0' || ((max_len) >= 0 && (i) >= (max_len))) \
+ goto failed; \
} while (0)
@@ -559,7 +559,7 @@ gboolean g_utf8_validate(const gchar *str, gssize max_len, const gchar **end)
if ((p[i] & 0xe0) == 0xc0) { /* 110xxxxx */
if ((p[i] & 0x1e) == 0)
goto failed;
- INCREMENT_AND_CHECK_MAX(i, max_len);
+ INCREMENT_AND_CHECK_MAX(p, i, max_len);
if ((p[i] & 0xc0) != 0x80)
goto failed; /* 10xxxxxx */
} else {
@@ -575,13 +575,13 @@ gboolean g_utf8_validate(const gchar *str, gssize max_len, const gchar **end)
} else
goto failed;
- INCREMENT_AND_CHECK_MAX(i, max_len);
+ INCREMENT_AND_CHECK_MAX(p, i, max_len);
CONTINUATION_CHAR(p[i], val);
two_remaining:
- INCREMENT_AND_CHECK_MAX(i, max_len);
+ INCREMENT_AND_CHECK_MAX(p, i, max_len);
CONTINUATION_CHAR(p[i], val);
- INCREMENT_AND_CHECK_MAX(i, max_len);
+ INCREMENT_AND_CHECK_MAX(p, i, max_len);
CONTINUATION_CHAR(p[i], val);
if (val < min || !UNICODE_VALID(val))