Commit 5e956311 by Ralf W. Grosse-Kunstleve Committed by Copybara-Service

Change test to avoid UBSAN error.

Preparation for enabling presubmit UBSAN testing.

UBSAN error fixed by this CL:

```
SUMMARY: UndefinedBehaviorSanitizer: nullptr-with-nonzero-offset third_party/pybind11_abseil/tests/status_example.cc:111:66 in
```
PiperOrigin-RevId: 485136235
parent ef7a738c
...@@ -108,7 +108,10 @@ PYBIND11_MODULE(status_example, m) { ...@@ -108,7 +108,10 @@ PYBIND11_MODULE(status_example, m) {
m.def("make_bad_capsule", [](bool pass_name) { m.def("make_bad_capsule", [](bool pass_name) {
// https://docs.python.org/3/c-api/capsule.html: // https://docs.python.org/3/c-api/capsule.html:
// The pointer argument may not be NULL. // The pointer argument may not be NULL.
return capsule(static_cast<void*>(static_cast<int*>(nullptr) + 1), int dummy_pointee[] = {}; // This will become a dangling pointer when this
// function returns: We don't want the pointer to be used. Hopefully if it
// is used unintentionally, one of the sanitizers will flag it.
return capsule(static_cast<void*>(dummy_pointee),
pass_name ? "NotGood" : nullptr); pass_name ? "NotGood" : nullptr);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment