Could this change to PyRun_SimpleStringFlags cause an "Access violation" error?

I’m currently working on my custom cpython version and recently I’ve started seeing an access violation error when using it. I think I narrowed down my issue and I would like to ask a very specific question without providing extra context.

Consider the following function (I’m using this exact commit):

I want to know if this small change could cause an access violation if flags actually turn out to be NULL.

The error in my python app that is run by this custom cpython build looks like this:

Returning 0 (NULL) from functions like this implies that you’ve set an exception. You haven’t here, so on the face of it, I would assume that it’s going to get something confused, but I’d have to test to see exactly what happens.


Check PyRun_StringFlags to see what it does when passed a NULL pointer.

C is certainly the kind of language where dereferencing a NULL pointer can be a bad thing.

For a taste of the sorts of things a language runtime can do, perhaps skim: