changeset 12914:746b4e9e7015

lib-settings: Fixed crash when trying treat strlist as having a subsection. For example "plugin/foo/bar=yes" crashed, while it should have been just ignored.
author Timo Sirainen <tss@iki.fi>
date Sat, 26 Mar 2011 01:10:59 +0200
parents 0d437e2e6949
children 3eaf0d3a38d4
files src/lib-settings/settings-parser.c
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-settings/settings-parser.c	Sat Mar 26 00:42:48 2011 +0200
+++ b/src/lib-settings/settings-parser.c	Sat Mar 26 01:10:59 2011 +0200
@@ -693,8 +693,15 @@
 		if (!settings_find_key_nth(ctx, parent_key, &parent_n,
 					   &parent_def, &parent_link))
 			return FALSE;
-		if (parent_def->type != SET_STRLIST)
-			return FALSE;
+		if (parent_def == NULL) {
+			/* we'll get here with e.g. "plugin/a/b=val".
+			   not sure if we should ever do anything here.. */
+			if (strcmp(parent_link->full_key, parent_key) != 0)
+				return FALSE;
+		} else {
+			if (parent_def->type != SET_STRLIST)
+				return FALSE;
+		}
 
 		/* setting parent_key=0 adds it to links list */
 		if (settings_parse_keyvalue(ctx, parent_key, "0") <= 0)