Fix undefined behavior in Block access

Reference issue

Fixes #2482 (closed).

What does this implement/fix?

Avoids undefined behavior in Block access.

Pointer arithmetic on null pointers is undefined behavior in C++.

See the issue for more details.

Additional information

I've put this through its paces in my own codebase.

In this merge request I've tested with and without the patch.

Without the patch here and here you can see the handful of UBSan errors. With the patch, those all go away here and here.

Merge request reports

Loading