aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Jason Nader <jason.nader@protonmail.com>2021-10-25 13:28:32 +0900
committerLibravatar Simon Ser <contact@emersion.fr>2021-10-25 10:18:40 +0200
commit9303bed4d4523d158b33c44f534a53b21d7688d6 (patch)
tree55965bc247a85cac9c240a1e5715a7a9f6c38ddb
parentrefactor: use sway_abort instead (diff)
downloadsway-9303bed4d4523d158b33c44f534a53b21d7688d6.tar.gz
sway-9303bed4d4523d158b33c44f534a53b21d7688d6.tar.zst
sway-9303bed4d4523d158b33c44f534a53b21d7688d6.zip
refactor: use JSON_MAX_DEPTH everywhere
-rw-r--r--include/ipc-client.h3
-rw-r--r--swaybar/ipc.c2
-rw-r--r--swaymsg/main.c3
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 @@
1#ifndef _SWAY_IPC_CLIENT_H 1#ifndef _SWAY_IPC_CLIENT_H
2#define _SWAY_IPC_CLIENT_H 2#define _SWAY_IPC_CLIENT_H
3 3
4// arbitrary number, it's probably sufficient, higher number = more memory usage
5#define JSON_MAX_DEPTH 512
6
4#include <stdbool.h> 7#include <stdbool.h>
5#include <stdint.h> 8#include <stdint.h>
6#include <sys/time.h> 9#include <sys/time.h>
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) {
550 // The default depth of 32 is too small to represent some nested layouts, but 550 // The default depth of 32 is too small to represent some nested layouts, but
551 // we can't pass INT_MAX here because json-c (as of this writing) prefaults 551 // we can't pass INT_MAX here because json-c (as of this writing) prefaults
552 // all the memory for its stack. 552 // all the memory for its stack.
553 json_tokener *tok = json_tokener_new_ex(256); 553 json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH);
554 if (!tok) { 554 if (!tok) {
555 sway_log_errno(SWAY_ERROR, "failed to create tokener"); 555 sway_log_errno(SWAY_ERROR, "failed to create tokener");
556 free_ipc_response(resp); 556 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 @@
1#define _POSIX_C_SOURCE 200809L 1#define _POSIX_C_SOURCE 200809L
2 2
3// arbitrary number, it's probably sufficient, higher number = more memory usage
4#define JSON_MAX_DEPTH 512
5
6#include <limits.h> 3#include <limits.h>
7#include <stdio.h> 4#include <stdio.h>
8#include <stdlib.h> 5#include <stdlib.h>