diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2015-02-02 14:58:23 -0800 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2015-02-02 14:58:23 -0800 |
commit | 535bc2fe2f2b467f59347ffc9449e11e47791257 (patch) | |
tree | 9118ed49059d215c189aaef332dcf2335a0ad8b7 /upb/json/printer.c | |
parent | 17be1ef0f246aa7add98c04efce3e0b992abccc4 (diff) | |
parent | 099d57346ad36e4d65de559d3ac56b99b54b374a (diff) |
Merge pull request #13 from cfallin/json-maps
Fixed JSON parser issue: missing NUL byte in parse_number() in some code paths.
Diffstat (limited to 'upb/json/printer.c')
-rw-r--r-- | upb/json/printer.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/upb/json/printer.c b/upb/json/printer.c index bb748ec..deae058 100644 --- a/upb/json/printer.c +++ b/upb/json/printer.c @@ -187,7 +187,9 @@ static bool putkey(void *closure, const void *handler_data) { print_comma(p); \ CHK(put##type(closure, handler_data, val)); \ return true; \ - } \ + } + +#define TYPE_HANDLERS_MAPKEY(type, fmt_func) \ static bool putmapkey_##type(void *closure, const void *handler_data, \ type val) { \ upb_json_printer *p = closure; \ @@ -205,7 +207,15 @@ TYPE_HANDLERS(uint32_t, fmt_int64); TYPE_HANDLERS(int64_t, fmt_int64); TYPE_HANDLERS(uint64_t, fmt_uint64); +// double and float are not allowed to be map keys. +TYPE_HANDLERS_MAPKEY(bool, fmt_bool); +TYPE_HANDLERS_MAPKEY(int32_t, fmt_int64); +TYPE_HANDLERS_MAPKEY(uint32_t, fmt_int64); +TYPE_HANDLERS_MAPKEY(int64_t, fmt_int64); +TYPE_HANDLERS_MAPKEY(uint64_t, fmt_uint64); + #undef TYPE_HANDLERS +#undef TYPE_HANDLERS_MAPKEY typedef struct { void *keyname; |