From b173d05865e8102bb04b538a734d318e3024470e Mon Sep 17 00:00:00 2001 From: karliss Date: Wed, 4 Mar 2020 09:39:52 +0200 Subject: [PATCH] Limit amount of JSON dumped in case of error. (#2081) --- src/core/Cutter.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 1f27f6be..6592f5c7 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -445,7 +445,14 @@ QJsonDocument CutterCore::parseJson(const char *res, const char *cmd) } else { eprintf("Failed to parse JSON: %s\n", jsonError.errorString().toLocal8Bit().constData()); } - eprintf("%s\n", json.constData()); + const int MAX_JSON_DUMP_SIZE = 8 * 1024; + if (json.length() > MAX_JSON_DUMP_SIZE) { + int originalSize = json.length(); + json.resize(MAX_JSON_DUMP_SIZE); + eprintf("%d bytes total: %s ...\n", originalSize, json.constData()); + } else { + eprintf("%s\n", json.constData()); + } } return doc;