Skip to content

Commit 742463e

Browse files
DanBarzilianlostmsu
authored andcommitted
Increase ob's ref count in tp_repr to avoid accidental free
1 parent 9fb545a commit 742463e

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy