Skip to content

Fix crash in #12104 (cherry-pick)#12726

Merged
acozzette merged 1 commit intoprotocolbuffers:23.xfrom
acozzette:cherrypick-12104
May 9, 2023
Merged

Fix crash in #12104 (cherry-pick)#12726
acozzette merged 1 commit intoprotocolbuffers:23.xfrom
acozzette:cherrypick-12104

Conversation

@acozzette
Copy link
Copy Markdown

This crash was due to the fact that we were passing nullptr as a const char* parameter and relying on that implicitly converting into an empty absl::string_view. absl::string_view supports that functionality, but starting with C++17 its behavior changes since it's just a type alias for std::string_view. std::string_view does not have any special conversion for nullptr and so we were just getting crashes.

PiperOrigin-RevId: 530431663

This crash was due to the fact that we were passing `nullptr` as a `const
char*` parameter and relying on that implicitly converting into an empty
`absl::string_view`. `absl::string_view` supports that functionality, but
starting with C++17 its behavior changes since it's just a type alias for
`std::string_view`. `std::string_view` does not have any special conversion for
nullptr and so we were just getting crashes.

PiperOrigin-RevId: 530431663
@acozzette acozzette requested a review from a team as a code owner May 8, 2023 23:44
@acozzette acozzette requested review from a team, mkruskal-google and sbenzaquen and removed request for a team May 8, 2023 23:44
@acozzette acozzette added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 8, 2023
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label May 8, 2023
@acozzette acozzette merged commit 21b02b2 into protocolbuffers:23.x May 9, 2023
@acozzette acozzette deleted the cherrypick-12104 branch May 9, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants