lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx | 11 +++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
New commits: commit d9dc8731f5e06c65fb3228cddeb39bf90a2a6b10 Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sun Jul 21 14:22:57 2024 -0400 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Mon Jul 22 15:30:28 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/+/170743 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 e565b3f269fe..08da873e64b7 100644 --- a/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx +++ b/lingucomponent/source/spellcheck/languagetool/languagetoolimp.cxx @@ -217,7 +217,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)) {