Skip to content

Commit

Permalink
Fix crash when an invalid URI is parsed and error handling is attempted
Browse files Browse the repository at this point in the history
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
  • Loading branch information
crr0004 authored and kadircet committed Apr 7, 2021
1 parent f37ea62 commit 43637c0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 43637c0

Please sign in to comment.