Skip to content

Commit

Permalink
test small int test
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt committed Dec 23, 2024
1 parent b4c8444 commit 3a553d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3642,7 +3642,11 @@ _PyLong_ExactDealloc(PyObject *self)
static void
long_dealloc(PyObject *self)
{
if (_long_is_small_int(self)) {
// test what happens if we do hit the "never should get called": we should expect memory leaks, but no crashes
PyLongObject *pylong = (PyLongObject *)self;
int dotest = PyLong_CheckExact(self) && _PyLong_IsCompact(pylong) && (medium_value(pylong)==5);

if (_long_is_small_int(self) || dotest) {
/* This should never get called, but we also don't want to SEGV if
* we accidentally decref small Ints out of existence. Instead,
* since small Ints are immortal, re-set the reference count.
Expand Down

0 comments on commit 3a553d1

Please sign in to comment.