Bater quando o pixel processo após cortar uma imagem

Depois de usar essa função para recortar a imagem:

CGImageRef imageRef = CGImageCreateWithImageInRect([self.imageInput CGImage], rect);
UIImage *result = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);

Eu trago "resultado" para usar para processo com pixel assim:

......

CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef);
CGContextRelease(context);

// Now your rawData contains the image data in the RGBA8888 pixel format.
int byteIndex = 0;
for (NSInteger i = 0 ; i < width * height; i++) {
    int R = rawData[byteIndex];
    int G = rawData[byteIndex + 1];
    int B = rawData[byteIndex + 2];
    int test = [self getValueof:0.3* R + 0.59* G + 0.11 * B inRange:0 to:255];

    rawData[byteIndex] = (char)(test);
    rawData[byteIndex + 1] = (char)(test);
    rawData[byteIndex + 2] = (char)(test);
    byteIndex += 4;
}

ctx = CGBitmapContextCreate(rawData,
                            CGImageGetWidth( imageRef ),
                            CGImageGetHeight( imageRef ),
                            8,
                            CGImageGetBytesPerRow( imageRef ),
                            CGImageGetColorSpace( imageRef ),
                            kCGImageAlphaPremultipliedLast );
imageRef = CGBitmapContextCreateImage (ctx);
UIImage* rawImage = [UIImage imageWithCGImage:imageRef];
CGContextRelease(ctx);
CGImageRelease(imageRef);
free(rawData);

Eu vou ter um acidente? Alguém sabe sobre isso, por favor me ajude.

update crash report:: copy_read_only: vm_copy falhou: status 1.

questionAnswers(1)

yourAnswerToTheQuestion