Skip to content

Commit 5771cc4

Browse files
committed
Include msg length when sizing debug_cycle lines
1 parent 2087232 commit 5771cc4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎Python/gc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,14 +996,14 @@ clear_weakrefs(PyGC_Head *unreachable)
996996
}
997997
}
998998

999-
/* "gc: " + msg (at most "uncollectable") + " <" + " " + %p + ">\n" + NUL */
1000-
#define DEBUG_LINE_FIXED_LEN 64
999+
/* "gc: " + " <" + " " + %p + ">\n" + NUL, excluding msg and tp_name */
1000+
#define DEBUG_LINE_FIXED_LEN 32
10011001

10021002
static char *
10031003
debug_cycle(const char *msg, PyObject *op)
10041004
{
10051005
const char *name = Py_TYPE(op)->tp_name;
1006-
size_t size = strlen(name) + DEBUG_LINE_FIXED_LEN;
1006+
size_t size = strlen(msg) + strlen(name) + DEBUG_LINE_FIXED_LEN;
10071007
char *line = PyMem_RawMalloc(size);
10081008
if (line == NULL) {
10091009
return NULL;

0 commit comments

Comments
 (0)