[clang-tools-extra] r317580 - [clangd] don't crash on invalid JSON-RPC ID

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 7 06:45:31 PST 2017


Author: sammccall
Date: Tue Nov  7 06:45:31 2017
New Revision: 317580

URL: http://llvm.org/viewvc/llvm-project?rev=317580&view=rev
Log:
[clangd] don't crash on invalid JSON-RPC ID

Modified:
    clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=317580&r1=317579&r2=317580&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Nov  7 06:45:31 2017
@@ -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 C
           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);
         }
       }




More information about the cfe-commits mailing list