Skip to content

Commit 43637c0

Browse files
crr0004kadircet
authored andcommitted
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
1 parent f37ea62 commit 43637c0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ bool fromJSON(const llvm::json::Value &E, URIForFile &R, llvm::json::Path P) {
7070
if (auto S = E.getAsString()) {
7171
auto Parsed = URI::parse(*S);
7272
if (!Parsed) {
73+
consumeError(Parsed.takeError());
7374
P.report("failed to parse URI");
7475
return false;
7576
}

0 commit comments

Comments
 (0)