diff options
author | Mark Shannon <mark@hotpy.org> | 2022-09-06 15:45:43 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 15:45:43 (GMT) |
commit | 222f10ca2d01c86fa2c53c2edd6884f117324297 (patch) | |
tree | c20d440c56d7dcb87c3c083dc737d0443c22b1b3 /Include | |
parent | cd0ff9bd14d6a60e841d10f8415827db556ae622 (diff) | |
download | cpython-222f10ca2d01c86fa2c53c2edd6884f117324297.zip cpython-222f10ca2d01c86fa2c53c2edd6884f117324297.tar.gz cpython-222f10ca2d01c86fa2c53c2edd6884f117324297.tar.bz2 |
GH-96569: Add two NULL checks to avoid undefined behavior. (GH-96585)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/internal/pycore_frame.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Include/internal/pycore_frame.h b/Include/internal/pycore_frame.h index decaafd..5bd0a7f 100644 --- a/Include/internal/pycore_frame.h +++ b/Include/internal/pycore_frame.h @@ -190,11 +190,16 @@ _PyFrame_FastToLocalsWithError(_PyInterpreterFrame *frame); void _PyFrame_LocalsToFast(_PyInterpreterFrame *frame, int clear); - static inline bool _PyThreadState_HasStackSpace(PyThreadState *tstate, int size) { - return tstate->datastack_top + size < tstate->datastack_limit; + assert( + (tstate->datastack_top == NULL && tstate->datastack_limit == NULL) + || + (tstate->datastack_top != NULL && tstate->datastack_limit != NULL) + ); + return tstate->datastack_top != NULL && + size < tstate->datastack_limit - tstate->datastack_top; } extern _PyInterpreterFrame * |