Skip to content

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

Merged
mkruskal-google merged 1 commit intoprotocolbuffers:22.xfrom
acozzette:cherrypick-12104-fix
May 9, 2023
Merged

Fix crash in #12104 (cherry-pick)#12725
mkruskal-google merged 1 commit intoprotocolbuffers:22.xfrom
acozzette:cherrypick-12104-fix

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 mkruskal-google May 8, 2023 23:43
@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
@mkruskal-google mkruskal-google merged commit 74b12eb into protocolbuffers:22.x May 9, 2023
@acozzette acozzette deleted the cherrypick-12104-fix branch May 9, 2023 16:05
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