Fix a subtle use-after-free issue in XStatVisitor::RefValue()
The ternary expression here coerces both sides to the same type, which in this case is a std::string. As a result, it constructs a temporary std::string from the "" literal, and this temporary is then destroyed once the expression is evaluated, leaving nothing holding the backing data that the return value is bound to. The same problem happens with the other side, where a std::string is constructed from the std::string& reference returned by the protobuf accessor function. We fix this by explicitly binding both sides of the ternary expression to a string_view independently. PiperOrigin-RevId: 306551928 Change-Id: I2f5c812d32c32e955bb903eea4fbf30d236db089
Showing
想要评论请 注册 或 登录