title: Null pointer in CFRelease (told by static anylizer)
body: <p>I got this code:</p>
  
  <pre><code>- (void)saveImageWithData:(NSData*)jpeg andDictionary:(NSDictionary*)dicRef andName:(NSString*)name
  {
      self.capturedImageName = name;
      self.dict = dicRef;
  
      NSLog(@"%@",dicRef);
  
      CGImageSourceRef  source ;
      source = CGImageSourceCreateWithData((__bridge CFDataRef)jpeg, NULL);
  
      CFStringRef UTI = CGImageSourceGetType(source); //this is the type of image (e.g., public.jpeg)
  
      NSMutableData *dest_data = [NSMutableData data];
  
  
      CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)dest_data,UTI,1,NULL);
  
      if(!destination) {
          NSLog(@"***Could not create image destination ***");
      }
  
      //add the image contained in the image source to the destination, overwriting the old metadata with our modified metadata
      CGImageDestinationAddImageFromSource(destination,source,0, (__bridge CFDictionaryRef) dicRef);
  
      //tell the destination to write the image data and metadata into our data object.
      //It will return false if something goes wrong
      BOOL success = NO;
      success = CGImageDestinationFinalize(destination);
  
      if(!success) {
          NSLog(@"***Could not create data from image destination ***");
      }
  
      //now we have the data ready to go, so do whatever you want with it
      //here we just write it to disk at the same path we were passed
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
      NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
      NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"ARPictures"];
  
      NSError *error;
      if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
          [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&amp;error]; //Create folder
  
      NSString *fullPath = [dataPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.jpg", name]]; //add our image to the path
  
      [dest_data writeToFile:fullPath atomically:YES];
  
      self.img = [[UIImage alloc] initWithData:dest_data]; 
      self.capturedImageData = [[NSData alloc] initWithData:dest_data];
  
      //cleanup
  
      CFRelease(destination);
      CFRelease(source);
  
  }
  </code></pre>
  
  <p>But when I run the static analyzer it tells me that:</p>
  
  <blockquote>
    <p>Null pointer argument in call to CFRelease</p>
  </blockquote>
  
  <p>But according to my logic I should be releasing the CGImageSourceRef which is created by a <strong>CGImageDestinationCreateWithData</strong>. </p>
  
  <p>Also I am thinking that releasing it might be a mistake because i am just bridging it, which means arc still controls that object since its originally a <strong>NSMutableData</strong> object.</p>
  
  <p>To make matters worse i read that CFRelease(Null) is not good.</p>
  
  <p>I'm super confused, any help would be appreciated.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Ok i nslogged the pointers before sending them to the CFRelease, they are there!</p>
  
  <pre><code>2012-03-03 11:35:34.709 programtest[4821:707] &lt;CGImageDestination 0x331790 [0x3f92d630]&gt;
  
  2012-03-03 11:35:34.723 programtest[4821:707] &lt;CGImageSource 0x33ee80 [0x3f92d630]&gt;
  </code></pre>
  
  <p>So back to the original question, how why is the static analyzer telling me that i am sending a null pointer argument? and how do i fix/mute this?</p>
  
  <p>thanks</p>
  
  <p>PD: Is it possible that i am not sending a null pointer but a pointer to null?</p>