From: Matthias Clasen Date: Thu, 15 Apr 2004 13:58:29 +0000 (+0000) Subject: Add tests for the empty pattern. X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=f4d9fcd8d4682e5e34fd7fe6e854e71ab917b0df;p=dana%2Fcg-glib.git Add tests for the empty pattern. 2004-04-15 Matthias Clasen * tests/patterntest.c (main): Add tests for the empty pattern. * glib/gpattern.c (g_pattern_spec_new): Don't read and write out of bounds when the pattern is empty. (#140032, Stanislav Brabec, Stefan Fent) --- diff --git a/ChangeLog b/ChangeLog index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0f2db6d2..0d550a7d 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-04-15 Matthias Clasen + + * tests/patterntest.c (main): Add tests for the empty pattern. + + * glib/gpattern.c (g_pattern_spec_new): Don't read and write out + of bounds when the pattern is empty. (#140032, Stanislav Brabec, + Stefan Fent) + 2004-04-10 Tor Lillqvist * glib/gwin32.c (g_win32_getlocale): Add new language and diff --git a/glib/gpattern.c b/glib/gpattern.c index 302c6f75..68bafe81 100644 --- a/glib/gpattern.c +++ b/glib/gpattern.c @@ -243,7 +243,8 @@ g_pattern_spec_new (const gchar *pattern) pspec->pattern[pspec->pattern_length] = 0; return pspec; } - if (pspec->pattern[pspec->pattern_length - 1] == '*') + if (pspec->pattern_length > 0 && + pspec->pattern[pspec->pattern_length - 1] == '*') { pspec->match_type = G_MATCH_HEAD; pspec->pattern[--pspec->pattern_length] = 0; diff --git a/tests/patterntest.c b/tests/patterntest.c index f5fd7b22..6dab50be 100644 --- a/tests/patterntest.c +++ b/tests/patterntest.c @@ -273,6 +273,8 @@ main (int argc, char** argv) TEST_MATCH("ab*", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "ab\xc3\xa4\xc3\xb6", TRUE); TEST_MATCH("ab*\xc3\xb6", "aba\xc3\xb6x\xc3\xb6", TRUE); + TEST_MATCH("", "", TRUE); + TEST_MATCH("", "abc", FALSE); verbose ("\n%u tests passed, %u failed\n", passed, failed);