ffi: fix segfault in _GET_TZINFO methods#2289
Conversation
adamreichold
left a comment
There was a problem hiding this comment.
The change looks good to me. I have to admit to feeling uneasy about ignoring the different struct layouts between PyDateTime_DateTime and PyDateTime_BaseDateTime. Is it ensured that we never write into a datetime that was allocated by someone else and might be missing that field? Maybe we could add a comment about this to the struct definition?
pickfire
left a comment
There was a problem hiding this comment.
Looks good to me, just slightly worried we are not doing the cast like C.
|
From the datetime docs (https://docs.python.org/3/library/datetime.html#available-types):
I think it's a bug if we ever write to these things. That said, I still agree we should be careful about the memory layout. I'll push the extra definitions in a follow-up PR. |
Looks like datetime types without
tzinfoset will not have space allocated for the null pointer, so we should checkhas_tzinfobefore trying to read it.