perfetto
perfetto copied to clipboard
DynamicString can be constructed from a temporary std::string, leading to a dangling pointer
The DynamicString constructor can be called with a temporary std::string, which leads to a use-after-free.
For example, the following code compiles, but results in str.value pointing to freed memory after the temporary std::string is destroyed:
perfetto::DynamicString str(std::string("hello") + std::string("world"));
TRACE_EVENT_INSTANT("mycategory", str);
This leads to corrupted trace event data that can be hard to debug.
It would be best to make this a compile-time error.
(Copied from internal bug b/417982839 for public tracking)
This was fixed by https://github.com/google/perfetto/pull/4272