diff options
-rw-r--r-- | swaymsg/main.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/swaymsg/main.c b/swaymsg/main.c index 3698294a..dcf42cb6 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c | |||
@@ -1,4 +1,8 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | |||
3 | // arbitrary number, it's probably sufficient, higher number = more memory usage | ||
4 | #define JSON_MAX_DEPTH 512 | ||
5 | |||
2 | #include <limits.h> | 6 | #include <limits.h> |
3 | #include <stdio.h> | 7 | #include <stdio.h> |
4 | #include <stdlib.h> | 8 | #include <stdlib.h> |
@@ -481,7 +485,7 @@ int main(int argc, char **argv) { | |||
481 | char *resp = ipc_single_command(socketfd, type, command, &len); | 485 | char *resp = ipc_single_command(socketfd, type, command, &len); |
482 | 486 | ||
483 | // pretty print the json | 487 | // pretty print the json |
484 | json_tokener *tok = json_tokener_new_ex(INT_MAX); | 488 | json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH); |
485 | if (tok == NULL) { | 489 | if (tok == NULL) { |
486 | sway_log(SWAY_ERROR, "failed allocating json_tokener"); | 490 | sway_log(SWAY_ERROR, "failed allocating json_tokener"); |
487 | ret = 1; | 491 | ret = 1; |
@@ -525,7 +529,7 @@ int main(int argc, char **argv) { | |||
525 | break; | 529 | break; |
526 | } | 530 | } |
527 | 531 | ||
528 | json_tokener *tok = json_tokener_new_ex(INT_MAX); | 532 | json_tokener *tok = json_tokener_new_ex(JSON_MAX_DEPTH); |
529 | if (tok == NULL) { | 533 | if (tok == NULL) { |
530 | sway_log(SWAY_ERROR, "failed allocating json_tokener"); | 534 | sway_log(SWAY_ERROR, "failed allocating json_tokener"); |
531 | ret = 1; | 535 | ret = 1; |