Skip to content
Myr

Skip printing what's below a MAX_PRINT_DEPTH

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This addresses #1136, and mitigates a stack exhaustion when printing a very deeply nested term.

authored by W-Mark Kubacki · committed by Nico Williams · parent 61b7563 · Browse files · 1 file+7 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−1 removed

  • other:+7 added−1 removed

1 file+7 added−1 removed

modified:src/jv_print.c+7 added-1 removed
11 unmodified lines
12#include "jv.h"13#include "jv_dtoa.h"14#include "jv_unicode.h"1516#ifndef MAX_PRINT_DEPTH17#define MAX_PRINT_DEPTH (256)18#endif1920#define ESC "\033"21#define COL(c) (ESC "[" c "m")22#define COLRESET (ESC "[0m")23
129 unmodified lines
153 break;154 }155 }156 }157 if (indent > MAX_PRINT_DEPTH) {158 put_str("<skipped: too deep>", F, S, flags & JV_PRINT_ISATTY);153 switch (jv_get_kind(x)) {159 } else switch (jv_get_kind(x)) {160 default:161 case JV_KIND_INVALID:162 if (flags & JV_PRINT_INVALID) {163 jv msg = jv_invalid_get_msg(jv_copy(x));
191 unmodified lines