From: crr0004 Date: Wed, 7 Apr 2021 10:31:41 +0000 (+0200) Subject: Fix crash when an invalid URI is parsed and error handling is attempted X-Git-Tag: llvmorg-14-init~10252 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43637c0dfeebcf4a4fcbb331f1094662e8882430;p=platform%2Fupstream%2Fllvm.git Fix crash when an invalid URI is parsed and error handling is attempted When you pass in a payload with an invalid URI in a build with assertions enabled, it will crash. Consuming the error from the failed URI parse prevents the error. The crash is caused by the [llvm::expected](https://llvm.org/doxygen/classllvm_1_1Expected.html) having protection around trying to deconstruct without consuming the error first. Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D99872 --- diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index 099c8531..de2f34c 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -70,6 +70,7 @@ bool fromJSON(const llvm::json::Value &E, URIForFile &R, llvm::json::Path P) { if (auto S = E.getAsString()) { auto Parsed = URI::parse(*S); if (!Parsed) { + consumeError(Parsed.takeError()); P.report("failed to parse URI"); return false; }