diff options
author | Behdad Esfahbod <pango@behdad.org> | 2005-08-26 18:52:17 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2005-08-26 18:52:17 +0000 |
commit | 85e1dc2e692f58032479f718b934aaf594c41f03 (patch) | |
tree | 059d17ce1b50ecd13aabed5db7367db6a5fcf339 /pango/break.c | |
parent | 875acbb3e2534eb58ae66b43299ab25171e4f8bb (diff) | |
download | pango-85e1dc2e692f58032479f718b934aaf594c41f03.tar.gz |
Protect against future line-break type additions in glib Unicode module.
2005-08-26 Behdad Esfahbod <pango@behdad.org>
* pango/break.c: Protect against future line-break type additions in
glib Unicode module.
Diffstat (limited to 'pango/break.c')
-rw-r--r-- | pango/break.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pango/break.c b/pango/break.c index c9bef4b4..cc123add 100644 --- a/pango/break.c +++ b/pango/break.c @@ -328,6 +328,8 @@ static const int line_break_indexes[] = { INDEX_WORD_JOINER }; +#define BREAK_TYPE_SAFE(btype) \ + (btype < G_N_ELEMENTS(line_break_indexes) ? btype : G_UNICODE_BREAK_UNKNOWN) #define BREAK_INDEX(btype) \ (line_break_indexes[(btype)]) #define BREAK_ROW(before_type) \ @@ -335,7 +337,7 @@ static const int line_break_indexes[] = { #define BREAK_OP(before_type, after_type) \ (BREAK_ROW (before_type)[BREAK_INDEX (after_type)]) #define IN_BREAK_TABLE(btype) \ - (btype <= G_N_ELEMENTS(line_break_indexes) && BREAK_INDEX(btype) < INDEX_END_OF_TABLE) + (btype < G_N_ELEMENTS(line_break_indexes) && BREAK_INDEX(btype) < INDEX_END_OF_TABLE) /* Keep these in sync with the same macros in the test program */ @@ -491,6 +493,7 @@ pango_default_break (const gchar *text, next_wc = '\n'; next_break_type = g_unichar_break_type (next_wc); + next_break_type = BREAK_TYPE_SAFE (next_break_type); for (i = 0; i <= n_chars; i++) { @@ -529,6 +532,7 @@ pango_default_break (const gchar *text, } next_break_type = g_unichar_break_type (next_wc); + next_break_type = BREAK_TYPE_SAFE (next_break_type); } type = g_unichar_type (wc); |