From 8f010ca870666ea136890d8c6317d0092cbe30ab Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 12 Sep 2024 10:27:05 +0300 Subject: another fix for #4643 --- libs/libjson/src/libJSON.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libs/libjson/src') diff --git a/libs/libjson/src/libJSON.cpp b/libs/libjson/src/libJSON.cpp index e52af2b6db..bd654fa70d 100644 --- a/libs/libjson/src/libJSON.cpp +++ b/libs/libjson/src/libJSON.cpp @@ -338,12 +338,24 @@ LIBJSON_DLL(JSONNode*) json_as_array(const JSONNode *node) { #ifdef JSON_WRITER LIBJSON_DLL(wchar_t*) json_write(const JSONNode *node) { JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write"), return toCString(EMPTY_CSTRING);); - return toCString(node->write()); + try { + return toCString(node->write()); + } + catch (...) { + Netlib_Logf(0, "Exception in writing JSON"); + } + return mir_wstrdup(L""); } LIBJSON_DLL(wchar_t*) json_write_formatted(const JSONNode *node) { JSON_ASSERT_SAFE(node, JSON_TEXT("null node to json_write_formatted"), return toCString(EMPTY_CSTRING);); - return toCString(node->write_formatted()); + try { + return toCString(node->write_formatted()); + } + catch (...) { + Netlib_Logf(0, "Exception in writing JSON"); + } + return mir_wstrdup(L""); } #endif -- cgit v1.2.3