Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

picture_image_device::get_bitmap can return a null reference #7298

Merged
merged 1 commit into from
Sep 27, 2020

Conversation

ksherlock
Copy link
Contributor

null references are not valid in C++ so compilers like to eliminate the null pointer check. This can result in a segfault,

eg, mame apple2e -gameio compeyes will segfault if no image (-pic) is provided.

switched to use a pointer instead.

null references are not valid/undefined in C++ so compilers like to
eliminate the null pointer check.

switched to returning a pointer instead.
@ajrhacker ajrhacker merged commit b89c075 into mamedev:master Sep 27, 2020
@cuavas
Copy link
Member

cuavas commented Sep 28, 2020

Since the MAME bitmap classes lazily allocate storage anyway, wouldn’t it be better to make picture_image_device always return a non-null bitmap and have the things that use it check .valid() on it instead? It would get rid of some indirection.

@ksherlock
Copy link
Contributor Author

The m_bitmap member variable is never used outside those functions (a2bus_computereyes2_device::write_c0nx, apple2_compeyes_device::an0_w) so it could be eliminated and replaced with a local reference instead of converting to a pointer.

@ksherlock ksherlock deleted the picture_image_device_get_bitmap branch June 9, 2023 01:52
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.

None yet

3 participants