aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2017-11-07 14:45:31 +0000
committerSam McCall <sam.mccall@gmail.com>2017-11-07 14:45:31 +0000
commit4e93cbe51ea0f967c45de0541a480aec48096eef (patch)
tree64dce9c5809923e0486ae5c2f4988d9ea4a48944
parent8eb5695e40cb0f15cfde7bcdfd8f5f1368c86214 (diff)
[clangd] don't crash on invalid JSON-RPC ID
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@317580 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clangd/JSONRPCDispatcher.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clangd/JSONRPCDispatcher.cpp b/clangd/JSONRPCDispatcher.cpp
index 52493b23..557fadba 100644
--- a/clangd/JSONRPCDispatcher.cpp
+++ b/clangd/JSONRPCDispatcher.cpp
@@ -12,6 +12,7 @@
#include "ProtocolHandlers.h"
#include "Trace.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/YAMLParser.h"
#include <istream>
@@ -149,7 +150,8 @@ bool JSONRPCDispatcher::call(StringRef Content, JSONOutput &Out) const {
ID.emplace(V.str());
} else {
double D;
- if (!V.getAsDouble(D))
+ // FIXME: this is locale-sensitive.
+ if (llvm::to_float(V, D))
ID.emplace(D);
}
}