summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--input/ipc.c2
-rw-r--r--misc/json.h2
-rw-r--r--player/lua.c2
-rw-r--r--test/json.c4
4 files changed, 5 insertions, 5 deletions
diff --git a/input/ipc.c b/input/ipc.c
index baf68aaf48..ea69fb7c24 100644
--- a/input/ipc.c
+++ b/input/ipc.c
@@ -126,7 +126,7 @@ static char *json_execute_command(struct mpv_handle *client, void *ta_parent,
bool async = false;
bool send_reply = true;
- rc = json_parse(ta_parent, &msg_node, &src, 50);
+ rc = json_parse(ta_parent, &msg_node, &src, MAX_JSON_DEPTH);
if (rc < 0) {
mp_err(log, "malformed JSON received: '%s'\n", src);
rc = MPV_ERROR_INVALID_PARAMETER;
diff --git a/misc/json.h b/misc/json.h
index 43d565b275..b99fc36c41 100644
--- a/misc/json.h
+++ b/misc/json.h
@@ -21,6 +21,8 @@
// We reuse mpv_node.
#include "libmpv/client.h"
+#define MAX_JSON_DEPTH 50
+
int json_parse(void *ta_parent, struct mpv_node *dst, char **src, int max_depth);
void json_skip_whitespace(char **src);
int json_write(char **s, struct mpv_node *src);
diff --git a/player/lua.c b/player/lua.c
index 80d0dc5b79..6a90d4f404 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -1163,7 +1163,7 @@ static int script_parse_json(lua_State *L, void *tmp)
bool trail = lua_toboolean(L, 2);
bool ok = false;
struct mpv_node node;
- if (json_parse(tmp, &node, &text, 32) >= 0) {
+ if (json_parse(tmp, &node, &text, MAX_JSON_DEPTH) >= 0) {
json_skip_whitespace(&text);
ok = !text[0] || trail;
}
diff --git a/test/json.c b/test/json.c
index fb6633accf..8aeae2326e 100644
--- a/test/json.c
+++ b/test/json.c
@@ -63,8 +63,6 @@ static const struct entry entries[] = {
NODE_MAP(L("_a12"), L(NODE_STR("b")))},
};
-#define MAX_DEPTH 10
-
int main(void)
{
for (int n = 0; n < MP_ARRAY_SIZE(entries); n++) {
@@ -73,7 +71,7 @@ int main(void)
char *s = talloc_strdup(tmp, e->src);
json_skip_whitespace(&s);
struct mpv_node res;
- bool ok = json_parse(tmp, &res, &s, MAX_DEPTH) >= 0;
+ bool ok = json_parse(tmp, &res, &s, MAX_JSON_DEPTH) >= 0;
assert_true(ok != e->expect_fail);
if (!ok) {
talloc_free(tmp);