mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-15 18:10:06 +02:00
Add tests for the empty pattern.
2004-04-15 Matthias Clasen <mclasen@redhat.com> * 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)
This commit is contained in:
committed by
Matthias Clasen
parent
817f25b95b
commit
f4d9fcd8d4
@@ -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;
|
||||
|
Reference in New Issue
Block a user