Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8564cd

Browse files
committed
Be more careful with negative reference counts.
1 parent 3d54f2d commit c8564cd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Include/object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ whose size is determined when the object is allocated.
5656
#ifdef TRACE_REFS
5757
#define OB_HEAD \
5858
struct _object *_ob_next, *_ob_prev; \
59-
unsigned int ob_refcnt; \
59+
int ob_refcnt; \
6060
struct _typeobject *ob_type;
6161
#define OB_HEAD_INIT(type) 0, 0, 1, type,
6262
#else
@@ -200,15 +200,15 @@ extern long ref_total;
200200
#endif
201201
#define INCREF(op) (ref_total++, (op)->ob_refcnt++)
202202
#define DECREF(op) \
203-
if (--ref_total, --(op)->ob_refcnt != 0) \
203+
if (--ref_total, --(op)->ob_refcnt > 0) \
204204
; \
205205
else \
206206
DELREF(op)
207207
#else
208208
#define NEWREF(op) ((op)->ob_refcnt = 1)
209209
#define INCREF(op) ((op)->ob_refcnt++)
210210
#define DECREF(op) \
211-
if (--(op)->ob_refcnt != 0) \
211+
if (--(op)->ob_refcnt > 0) \
212212
; \
213213
else \
214214
DELREF(op)

0 commit comments

Comments
 (0)