@@ -203,6 +203,7 @@ static int wait_for_stdin(void)
203203 if (interrupted) raise (SIGINT);
204204 }
205205 CFReadStreamClose (stream);
206+ CFRelease (stream);
206207 return 1 ;
207208}
208209
@@ -2103,6 +2104,7 @@ static int _find_maximum(CGFloat values[3])
21032104 function,
21042105 true ,
21052106 true );
2107+ CGColorSpaceRelease (colorspace);
21062108 CGFunctionRelease (function);
21072109 if (shading)
21082110 {
@@ -2236,6 +2238,7 @@ static CGRect _find_enclosing_rect(CGPoint points[3])
22362238 CGImageRef mask = CGBitmapContextCreateImage (bitmap);
22372239 CGContextClipToMask (cr, rect, mask);
22382240 CGImageRelease (mask);
2241+ CGContextRelease (bitmap);
22392242 free (data);
22402243 return 0 ;
22412244}
@@ -3990,9 +3993,9 @@ static void _data_provider_release(void* info, const void* data, size_t size)
39903993 if (window)
39913994 {
39923995 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc ] init ];
3993- NSString * ns_title = [[NSString alloc ]
3994- initWithCString: title
3995- encoding: NSUTF8StringEncoding];
3996+ NSString * ns_title = [[[ NSString alloc ]
3997+ initWithCString: title
3998+ encoding: NSUTF8StringEncoding] autorelease ];
39963999 [window setTitle: ns_title];
39974000 [pool release ];
39984001 }
@@ -4489,7 +4492,12 @@ -(void)save_figure:(id)sender
44894492 NSMenu * menu = [button menu ];
44904493 NSArray * items = [menu itemArray ];
44914494 unsigned int n = [items count ];
4492- int * states = malloc (n*sizeof (int ));
4495+ int * states = calloc (n, sizeof (int ));
4496+ if (!states)
4497+ {
4498+ PyErr_SetString (PyExc_RuntimeError, " calloc failed" );
4499+ return NULL ;
4500+ }
44934501 int i;
44944502 unsigned int m = 0 ;
44954503 NSEnumerator * enumerator = [items objectEnumerator ];
@@ -4504,7 +4512,6 @@ -(void)save_figure:(id)sender
45044512 states[i] = 1 ;
45054513 m++;
45064514 }
4507- else states[i] = 0 ;
45084515 }
45094516 int j = 0 ;
45104517 PyObject* list = PyList_New (m);
0 commit comments