CoreImage createCGImage Crash

I found that the app reported a crash of a pure virtual function call, which could not be reproduced.

A third-party library is referenced: https://github.com/lincf0912/LFPhotoBrowser

Achieve smearing, blurring, and mosaic processing of images

Crash code:

if (![LFSmearBrush smearBrushCache]) {

			[_edit_toolBar setSplashWait:YES index:LFSplashStateType_Smear];

			CGSize canvasSize = AVMakeRectWithAspectRatioInsideRect(self.editImage.size, _EditingView.bounds).size;

			[LFSmearBrush loadBrushImage:self.editImage canvasSize:canvasSize useCache:YES complete:^(BOOL success) {

			         [weakToolBar setSplashWait:NO index:LFSplashStateType_Smear];

			 }];

		}
- (UIImage *)LFBB_patternGaussianImageWithSize:(CGSize)size orientation:(CGImagePropertyOrientation)orientation filterHandler:(CIFilter *(^ _Nullable )(CIImage *ciimage))filterHandler
{
    CIContext *context = LFBrush_CIContext;
    NSAssert(context != nil, @"This method must be called using the LFBrush class.");
    CIImage *midImage = [CIImage imageWithCGImage:self.CGImage];
    midImage = [midImage imageByApplyingTransform:[self LFBB_preferredTransform]];
    midImage = [midImage imageByApplyingTransform:CGAffineTransformMakeScale(size.width/midImage.extent.size.width,size.height/midImage.extent.size.height)];
        
    if (orientation > 0 && orientation < 9) {
        midImage = [midImage imageByApplyingOrientation:orientation];
    }
    //图片开始处理
    CIImage *result = midImage;
    if (filterHandler) {
        CIFilter *filter = filterHandler(midImage);
        if (filter) {
            result = filter.outputImage;
        }
    }
        
    CGImageRef outImage = [context createCGImage:result fromRect:[midImage extent]];
    UIImage *image = [UIImage imageWithCGImage:outImage];
    CGImageRelease(outImage);
    
    return image;
}

This line trigger crash:

CGImageRef outImage = [context createCGImage:result fromRect:[midImage extent]];

+ (void)loadBrushImage:(UIImage *)image canvasSize:(CGSize)canvasSize useCache:(BOOL)useCache complete:(void (^ _Nullable )(BOOL success))complete
{
    if (!useCache) {
        [[LFBrushCache share] removeObjectForKey:LFSmearBrushImage];
    }
    UIImage *cacheImage = [[LFBrushCache share] objectForKey:LFSmearBrushImage];
    if (cacheImage) {
        if (complete) {
            complete(YES);
        }
        return;
    }
    if (image) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
            
            UIImage *patternImage = [image LFBB_patternGaussianImageWithSize:canvasSize filterHandler:nil];
            dispatch_async(dispatch_get_main_queue(), ^{
                
                if (patternImage) {
                    [[LFBrushCache share] setForceObject:patternImage forKey:LFSmearBrushImage];
                }
                
                if (complete) {
                    complete((BOOL)patternImage);
                }
            });
        });
    } else {
        if (complete) {
            complete(NO);
        }
    }
}
CoreImage createCGImage Crash
 
 
Q