summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-09-07 12:38:56 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-09-07 12:38:56 +0000
commitcde88418f304c4b62d83f142b9bfd7818aa34613 (patch)
tree92ce2fce79d42cfc66d20af78c1062e27dcbc136 /json.c
parentbd6680b29c898ffef331532dc97f9dd0986f3516 (diff)
downloadgpsd-cde88418f304c4b62d83f142b9bfd7818aa34613.tar.gz
Enable JSON parser to recognize a type mismatch.
Diffstat (limited to 'json.c')
-rw-r--r--json.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/json.c b/json.c
index 8262dbcb..b0bdd7fb 100644
--- a/json.c
+++ b/json.c
@@ -98,7 +98,7 @@ static int json_internal_read_object(const char *cp, const struct json_attr_t *a
#ifdef JSONDEBUG
char *statenames[] = {
"init", "await_attr", "in_attr", "await_value",
- "in_val_string", "in_val_token", "post_val"
+ "in_val_string", "in_escape", "in_val_token", "post_val"
};
#endif /* JSONDEBUG */
char attrbuf[JSON_ATTR_MAX+1], *pattr = NULL;
@@ -219,6 +219,10 @@ static int json_internal_read_object(const char *cp, const struct json_attr_t *a
json_debug_trace(("Array element was specified, but no [.\n"));
return JSON_ERR_NOBRAK;
} else if (*cp == '"') {
+ if (cursor->type != string) {
+ json_debug_trace(("Saw string quote when expecting non-string.\n"));
+ return JSON_ERR_QNONSTRING;
+ }
state = in_val_string;
pval = valbuf;
} else {
@@ -464,6 +468,7 @@ const char *json_error_string(int err)
"check attribute not matched",
"can't support strings in parallel arrays",
"invalid enumerated value",
+ "saw string quote when expecting nonstring",
"other data conversion error",
};