diff --git a/daemon/control_ng.c b/daemon/control_ng.c index e0507eab3..5bacccfb5 100644 --- a/daemon/control_ng.c +++ b/daemon/control_ng.c @@ -101,6 +101,9 @@ static bool bencode_dict_iter(ng_parser_ctx_t *ctx, bencode_item_t *input, return true; } +static bool bencode_is_dict(bencode_item_t *arg) { + return arg->type == BENCODE_DICTIONARY; +} static bool bencode_is_list(bencode_item_t *arg) { return arg->type == BENCODE_LIST; } @@ -143,6 +146,7 @@ const ng_parser_t ng_parser_native = { .get_int_str = bencode_get_integer_str, .is_int = bencode_is_int, .get_int = bencode_get_int, + .is_dict = bencode_is_dict, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, .dict_add = bencode_dictionary_add, @@ -166,6 +170,7 @@ const ng_parser_t ng_parser_json = { .get_int_str = bencode_get_integer_str, .is_int = bencode_is_int, .get_int = bencode_get_int, + .is_dict = bencode_is_dict, .dict = __bencode_dict, .dict_get_str = bencode_dictionary_get_str, .dict_add = bencode_dictionary_add, diff --git a/daemon/statistics.c b/daemon/statistics.c index 6890e07aa..e3f9d61a9 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -1003,7 +1003,7 @@ const char *statistics_ng(ng_parser_ctx_t *ctx) { assert(sub != NULL); // is this a dictionary? - if (dict->type == BENCODE_DICTIONARY) { + if (ctx->parser->is_dict(dict)) { assert(sub_label != NULL); ctx->parser->dict_add(dict, bencode_strdup(buf, sub_label), sub); } diff --git a/include/control_ng.h b/include/control_ng.h index e7548ec32..4c80063ba 100644 --- a/include/control_ng.h +++ b/include/control_ng.h @@ -125,6 +125,7 @@ struct ng_parser { long long (*get_int_str)(bencode_item_t *, long long def); bool (*is_int)(bencode_item_t *); long long (*get_int)(bencode_item_t *); + bool (*is_dict)(bencode_item_t *); bencode_item_t *(*dict)(ng_parser_ctx_t *); char *(*dict_get_str)(bencode_item_t *, const char *, str *); bencode_item_t *(*dict_add)(bencode_item_t *, const char *, bencode_item_t *);