refactor: use JSON_MAX_DEPTH everywhere

This commit is contained in:
Jason Nader 2021-10-25 13:28:32 +09:00 committed by Simon Ser
parent b223f70250
commit 9303bed4d4
3 changed files with 4 additions and 4 deletions

View file

@ -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 <stdbool.h>
#include <stdint.h>
#include <sys/time.h>

View file

@ -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);

View file

@ -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 <limits.h>
#include <stdio.h>
#include <stdlib.h>