Skip to content

Commit 158e27b

Browse files
committed
Ensure co_stacksize >= 1, else RETURN_CONST may crash
1 parent b59a3af commit 158e27b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Objects/codeobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ init_code(PyCodeObject *co, struct _PyCodeConstructor *con)
395395
int nlocals, ncellvars, nfreevars;
396396
get_localsplus_counts(con->localsplusnames, con->localspluskinds,
397397
&nlocals, &ncellvars, &nfreevars);
398+
if (con->stacksize == 0) {
399+
con->stacksize = 1;
400+
}
398401

399402
co->co_filename = Py_NewRef(con->filename);
400403
co->co_name = Py_NewRef(con->name);

0 commit comments

Comments
 (0)