[all-commits] [llvm/llvm-project] fceaf8: [clang] Fix UB when string.front() is used for the...

Dmitry Polukhin via All-commits all-commits at lists.llvm.org
Wed Jun 30 01:16:38 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fceaf8621179aa758c44f3eaee02d789abfd455b
      https://github.com/llvm/llvm-project/commit/fceaf8621179aa758c44f3eaee02d789abfd455b
  Author: Dmitry Polukhin <dmitry.polukhin at gmail.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

  Changed paths:
    M clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
    M clang/unittests/Tooling/CompilationDatabaseTest.cpp

  Log Message:
  -----------
  [clang] Fix UB when string.front() is used for the empty string

Compilation database might have empty string as a command line argument.
But ExpandResponseFilesDatabase::expand doesn't expect this and assumes
that string.front() can be used for any argument. It is undefined behaviour if
string is empty. With debug build mode it causes crash in clangd.

Test Plan: check-clang

Differential Revision: https://reviews.llvm.org/D105120




More information about the All-commits mailing list