[llvm-bugs] [Bug 34729] New: std::string_view encourages use-after-free

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 25 22:56:37 PDT 2017


            Bug ID: 34729
           Summary: std::string_view encourages use-after-free
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kcc at google.com
                CC: eric at efcs.ca, llvm-bugs at lists.llvm.org,
                    mclow.lists at gmail.com

% cat string_view_uaf.cc 
#include <iostream>
#include <string>
#include <string_view>

int main() {
  std::string s = "Hellooooooooooooooo ";
  std::string_view sv = s + "World\n";
  std::cout << sv;
% clang++ -std=c++11 string_view_uaf.cc -stdlib=libc++ -fsanitize=address &&
 ?ooooooooooooooo World
==15854==ERROR: AddressSanitizer: heap-use-after-free

I don't know if this is a libc++ bug or a C++17 feature, please advise.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170926/00245b9e/attachment-0001.html>

More information about the llvm-bugs mailing list