Skip to content

Commit 8e8f205

Browse files
DanBarzilianfilmor
authored andcommitted
Increase ob's ref count in tp_repr to avoid accidental free
1 parent 801525a commit 8e8f205

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

AUTHORS.md

+1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,5 @@
7373
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
7474
- ([@stonebig](https://github.com/stonebig))
7575
- ([@testrunner123](https://github.com/testrunner123))
76+
- ([@DanBarzilian](https://github.com/DanBarzilian))
7677

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
1313

1414
### Fixed
1515

16+
- Fix incorrect dereference of wrapper object in tp_repr, which may result in a program crash
17+
1618
## [2.5.0][] - 2020-06-14
1719

1820
This version improves performance on benchmarks significantly compared to 2.3.

src/runtime/classbase.cs

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ public static IntPtr tp_repr(IntPtr ob)
266266

267267
//otherwise use the standard object.__repr__(inst)
268268
IntPtr args = Runtime.PyTuple_New(1);
269+
Runtime.XIncref(ob);
269270
Runtime.PyTuple_SetItem(args, 0, ob);
270271
IntPtr reprFunc = Runtime.PyObject_GetAttrString(Runtime.PyBaseObjectType, "__repr__");
271272
var output = Runtime.PyObject_Call(reprFunc, args, IntPtr.Zero);

0 commit comments

Comments
 (0)