[PATCH] D85525: [clang-tidy] Fix a crash in bugprone-not-null-terminated-result check when `__STDC_WANT_LIB_EXT1__` is not a literal.

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 7 07:34:53 PDT 2020


ArcsinX added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:806
         const auto &T = MI->tokens().back();
-        StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
-        llvm::APInt IntValue;
-        ValueStr.getAsInteger(10, IntValue);
-        AreSafeFunctionsWanted = IntValue.getZExtValue();
+        if (T.isLiteral()) {
+          StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
----------------
hokein wrote:
> let's add the `getLiteralData` check here --  `if (T.isLiteral() && T.getLiteralData())`
Could we also add clangd test here for that case (when `T.isLiteral() == true` and `T.getLiteralData() == nullptr`)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85525/new/

https://reviews.llvm.org/D85525



More information about the cfe-commits mailing list