diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | src/validate.c | 11 |
2 files changed, 22 insertions, 1 deletions
@@ -1,3 +1,15 @@ +2008-02-05 Vincent Untz <vuntz@gnome.org> + + Fix crash with really small lines that are invalid, like just "a". + Fox bug #14386. + + * src/validate.c: (validate_line_looks_like_group): only return + something in *group if the group argument is not NULL, and if the line + is actually a group one + (validate_parse_line): ensure we pass NULL initial values to some + functions, and don't leak key and value when processing a key-value + line before the first group + 2008-01-20 Vincent Untz <vuntz@gnome.org> * src/update-desktop-database.c: (process_desktop_file): don't get the diff --git a/src/validate.c b/src/validate.c index 702a78c..3474e0e 100644 --- a/src/validate.c +++ b/src/validate.c @@ -1911,7 +1911,8 @@ validate_line_looks_like_group (kf_validator *kf, "The validation will continue, with the trailing spaces " "ignored.\n", line); - *group = g_strndup (chomped + 1, strlen (chomped) - 2); + if (group && result) + *group = g_strndup (chomped + 1, strlen (chomped) - 2); g_free (chomped); @@ -1988,6 +1989,7 @@ validate_parse_line (kf_validator *kf) if (validate_line_is_comment (kf, line)) return; + group = NULL; if (validate_line_looks_like_group (kf, line, &group)) { if (!kf->current_group && (strcmp (group, GROUP_DESKTOP_ENTRY) && @@ -2012,6 +2014,8 @@ validate_parse_line (kf_validator *kf) return; } + key = NULL; + value = NULL; if (validate_line_looks_like_entry (kf, line, &key, &value)) { if (kf->current_group) { GSList *keys; @@ -2025,6 +2029,11 @@ validate_parse_line (kf_validator *kf) keys = g_slist_prepend (keys, keyvalue); g_hash_table_replace (kf->groups, g_strdup (kf->current_group), keys); } else { + if (key) + g_free (key); + if (value) + g_free (value); + print_fatal (kf, "file contains entry \"%s\" before the first group, " "but only comments are accepted before the first " "group\n", line); |