Malloc Crash when creating UIImage?

I know it a little in common, but we did EVERY possible thing to find what it was, and we just couldn't.

We have this glitch that happens here and there, not always, on this line:

[self.imageOperationQueue addOperationWithBlock:^
 {
    if(!data)
        return ;
    UIImage *image=[[UIImage alloc] initWithData:data]; // *** CRASH !

The crash log says:

malloc: *** error for object 0x7fecdb06e5c0: double free
*** set a breakpoint in malloc_error_break to debug

As you can see, and datawhen we check it is not null, when we create the image, we also tried: [UIImage initWithData:data];without selection, but the same thing.

EDIT: this is the code after this line:

       if(!data)
          return ;


      UIImage *image=[[UIImage alloc] initWithData:data];
      UIImageView *modelview=[self.allImageView objectAtIndex:index];
      float newH=image.size.height* (1.65*modelview.frame.size.width/image.size.width);
      CGSize s=CGSizeMake(1.65*modelview.frame.size.width, newH);

      if (image)
      {
          UIGraphicsBeginImageContextWithOptions(s , NO, 0.0);
          [image drawInRect:CGRectMake(0, 0, s.width, s.height)];

          image = UIGraphicsGetImageFromCurrentImageContext();
          UIGraphicsEndImageContext();
      }
+4
source share
1 answer

Yours datais most likely overfulfilled in another thread. A double-free indicates an imbalance in memory management, not a pointer.

, , data , , CoreGraphics NSData malloc'ed, . :

  • NSData
  • , NSData
  • -
  • , data
  • ARC , data
  • data free()
  • -

, NSData ; , , .

+3

All Articles