Skip to content

Commit ce17cf6

Browse files
committed
The CF inheritance could cause double frees of the underlying objects.
Fixed.
1 parent d9e50f5 commit ce17cf6

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

Mac/Modules/cf/_CFmodule.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ static void CFTypeRefObj_dealloc(CFTypeRefObject *self)
158158
if (self->ob_freeit && self->ob_itself)
159159
{
160160
self->ob_freeit((CFTypeRef)self->ob_itself);
161+
self->ob_itself = NULL;
161162
}
162163
self->ob_type->tp_free((PyObject *)self);
163164
}
@@ -519,6 +520,7 @@ static void CFArrayRefObj_dealloc(CFArrayRefObject *self)
519520
if (self->ob_freeit && self->ob_itself)
520521
{
521522
self->ob_freeit((CFTypeRef)self->ob_itself);
523+
self->ob_itself = NULL;
522524
}
523525
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
524526
}
@@ -728,6 +730,7 @@ static void CFMutableArrayRefObj_dealloc(CFMutableArrayRefObject *self)
728730
if (self->ob_freeit && self->ob_itself)
729731
{
730732
self->ob_freeit((CFTypeRef)self->ob_itself);
733+
self->ob_itself = NULL;
731734
}
732735
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
733736
}
@@ -966,6 +969,7 @@ static void CFDictionaryRefObj_dealloc(CFDictionaryRefObject *self)
966969
if (self->ob_freeit && self->ob_itself)
967970
{
968971
self->ob_freeit((CFTypeRef)self->ob_itself);
972+
self->ob_itself = NULL;
969973
}
970974
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
971975
}
@@ -1157,6 +1161,7 @@ static void CFMutableDictionaryRefObj_dealloc(CFMutableDictionaryRefObject *self
11571161
if (self->ob_freeit && self->ob_itself)
11581162
{
11591163
self->ob_freeit((CFTypeRef)self->ob_itself);
1164+
self->ob_itself = NULL;
11601165
}
11611166
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
11621167
}
@@ -1338,6 +1343,7 @@ static void CFDataRefObj_dealloc(CFDataRefObject *self)
13381343
if (self->ob_freeit && self->ob_itself)
13391344
{
13401345
self->ob_freeit((CFTypeRef)self->ob_itself);
1346+
self->ob_itself = NULL;
13411347
}
13421348
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
13431349
}
@@ -1561,6 +1567,7 @@ static void CFMutableDataRefObj_dealloc(CFMutableDataRefObject *self)
15611567
if (self->ob_freeit && self->ob_itself)
15621568
{
15631569
self->ob_freeit((CFTypeRef)self->ob_itself);
1570+
self->ob_itself = NULL;
15641571
}
15651572
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
15661573
}
@@ -1839,6 +1846,7 @@ static void CFStringRefObj_dealloc(CFStringRefObject *self)
18391846
if (self->ob_freeit && self->ob_itself)
18401847
{
18411848
self->ob_freeit((CFTypeRef)self->ob_itself);
1849+
self->ob_itself = NULL;
18421850
}
18431851
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
18441852
}
@@ -2564,6 +2572,7 @@ static void CFMutableStringRefObj_dealloc(CFMutableStringRefObject *self)
25642572
if (self->ob_freeit && self->ob_itself)
25652573
{
25662574
self->ob_freeit((CFTypeRef)self->ob_itself);
2575+
self->ob_itself = NULL;
25672576
}
25682577
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
25692578
}
@@ -2950,6 +2959,7 @@ static void CFURLRefObj_dealloc(CFURLRefObject *self)
29502959
if (self->ob_freeit && self->ob_itself)
29512960
{
29522961
self->ob_freeit((CFTypeRef)self->ob_itself);
2962+
self->ob_itself = NULL;
29532963
}
29542964
self->ob_type->tp_base->tp_dealloc((PyObject *)self);
29552965
}

Mac/Modules/cf/cfsupport.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def outputCleanupStructMembers(self):
273273
Output("if (self->ob_freeit && self->ob_itself)")
274274
OutLbrace()
275275
Output("self->ob_freeit((CFTypeRef)self->ob_itself);")
276+
Output("self->ob_itself = NULL;")
276277
OutRbrace()
277278

278279
def outputCompare(self):

0 commit comments

Comments
 (0)