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

Check that pointers are ok before access #134

Merged
merged 6 commits into from
Nov 15, 2024
Merged

Check that pointers are ok before access #134

merged 6 commits into from
Nov 15, 2024

Conversation

richfitz
Copy link
Member

The first part of a group of changes before I even get to Thom's problem.

This PR adds a check before every single access to a pointer that it is not NULL. This will prevent crashes when the user has serialised an object and tried to access it (which happens on save to disk).

I'll come up with a safe way of roundtripping a created model soon, but this will be much nicer than a crash at least!

Comment on lines 649 to 655
inline void check_externalptr_valid(SEXP ptr, const char * context) {
if (!R_ExternalPtrAddr(ptr)) {
cpp11::stop("Pointer has been serialised, cannot continue safely (%s)",
context);
}
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed!

@weshinsley weshinsley merged commit bd70020 into main Nov 15, 2024
8 checks passed
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