Skip to content

Commit cf28b95

Browse files
committed
Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
1 parent 0a0fc07 commit cf28b95

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,8 @@ Library
14921492
Extension Modules
14931493
-----------------
14941494

1495+
- Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
1496+
14951497
- Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
14961498
compared to other unix systems. In particular, os.getgroups() does
14971499
not reflect any changes made using os.setgroups() but basicly always

Modules/_struct.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,9 @@ prepare_s(PyStructObject *self)
12471247
PyErr_NoMemory();
12481248
return -1;
12491249
}
1250+
/* Free any s_codes value left over from a previous initialization. */
1251+
if (self->s_codes != NULL)
1252+
PyMem_FREE(self->s_codes);
12501253
self->s_codes = codes;
12511254

12521255
s = fmt;

0 commit comments

Comments
 (0)