forked from OSchip/llvm-project
[clangd] Don't crash on empty textDocument/didChange.
Found by clangd-fuzzer. llvm-svn: 316652
This commit is contained in:
parent
56a02ce91a
commit
b560a9a1b8
|
@ -73,6 +73,8 @@ void ClangdLSPServer::onDocumentDidOpen(Ctx C,
|
|||
|
||||
void ClangdLSPServer::onDocumentDidChange(Ctx C,
|
||||
DidChangeTextDocumentParams &Params) {
|
||||
if (Params.contentChanges.size() != 1)
|
||||
return C.replyError(-32602, "can only apply one change at a time");
|
||||
// We only support full syncing right now.
|
||||
Server.addDocument(Params.textDocument.uri.file,
|
||||
Params.contentChanges[0].text);
|
||||
|
|
|
@ -26,6 +26,10 @@ Content-Length: 246
|
|||
|
||||
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"struct fake { int a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n fake f;\n f.\n}\n"}}}
|
||||
|
||||
Content-Length: 104
|
||||
|
||||
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp"}}}
|
||||
|
||||
Content-Type: application/vscode-jsonrpc; charset-utf-8
|
||||
Content-Length: 146
|
||||
|
||||
|
|
Loading…
Reference in New Issue