From 9303bed4d4523d158b33c44f534a53b21d7688d6 Mon Sep 17 00:00:00 2001 From: Jason Nader Date: Mon, 25 Oct 2021 13:28:32 +0900 Subject: [PATCH] refactor: use JSON_MAX_DEPTH everywhere --- include/ipc-client.h | 3 +++ swaybar/ipc.c | 2 +- swaymsg/main.c | 3 --- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/ipc-client.h b/include/ipc-client.h index d3895023..9c5712d7 100644 --- a/include/ipc-client.h +++ b/include/ipc-client.h @@ -1,6 +1,9 @@ #ifndef _SWAY_IPC_CLIENT_H #define _SWAY_IPC_CLIENT_H +// arbitrary number, it's probably sufficient, higher number = more memory usage +#define JSON_MAX_DEPTH 512 + #include #include #include diff --git a/swaybar/ipc.c b/swaybar/ipc.c index a64aa1ab..2cb235bf 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -550,7 +550,7 @@ bool handle_ipc_readable(struct swaybar *bar) { // The default depth of 32 is too small to represent some nested layouts, but // we can't pass INT_MAX here because json-c (as of this writing) prefaults // all the memory for its stack. - json_tokener *tok = json_tokener_new_ex(256); + json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH); if (!tok) { sway_log_errno(SWAY_ERROR, "failed to create tokener"); free_ipc_response(resp); diff --git a/swaymsg/main.c b/swaymsg/main.c index e469319a..0d9dc5a0 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -1,8 +1,5 @@ #define _POSIX_C_SOURCE 200809L -// arbitrary number, it's probably sufficient, higher number = more memory usage -#define JSON_MAX_DEPTH 512 - #include #include #include