lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx | 11 +++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit d4d01d2dbb2babf8de86446e7f1d154d49c3672c Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sun Jul 21 14:22:57 2024 -0400 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Sat Jul 27 01:56:50 2024 +0200 tdf#161858 prevent crashing by catching any JSON exceptions Change-Id: I733ac428c96a96be668d6334db8c71efaf51beff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170818 Reviewed-by: Patrick Luby <guibomac...@gmail.com> Tested-by: Jenkins (cherry picked from commit d81ffa179df1d1279e98ff4aa5c58e1ea4720db1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170744 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx index fe912cb6b341..e0a9fd8a718d 100644 --- a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx +++ b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx @@ -210,7 +210,16 @@ uno::Sequence<SingleProofreadingError> parseJson(std::string&& json, std::string { std::stringstream aStream(std::move(json)); // Optimized in C++20 boost::property_tree::ptree aRoot; - boost::property_tree::read_json(aStream, aRoot); + + // tdf#161858 prevent crashing by catching any JSON exceptions + try + { + boost::property_tree::read_json(aStream, aRoot); + } + catch (std::runtime_error&) + { + SAL_WARN("languagetool", "parseJson: read_json() threw exception"); + } if (auto tree = aRoot.get_child_optional(path)) {