
Достаю увлажняющий гель для рук, салфетки, думаю - ну ща.
Дифф 3 линии:
Хип: 1024мб -> 2048мб
Цпу: 0.5 -> 2
и удаленние пустой строки в конце файла.
Size: a a a
com.google.common.collect.Iterators.concat
Note: the current implementation is not suitable for nested concatenated iterators, i.e. the following should be avoided when in a loop: iterator = Iterators.concat(iterator, suffix);, since iteration over the resulting iterator has a cubic complexity to the depth of the nesting.% 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 && ./a.out
?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.
LEWG/LWG considered this during the adoption of string_view, and decided that they were OK with it. (or, more accurately, that fixing this would make string_view much less useful).
So this is definitely a C++17 "feature".