Bug-fixed: add classtype asserts to avoid crash.

This commit is contained in:
PonyCui
2018-07-23 14:12:38 +08:00
parent 5c4ba4a351
commit 52be4cba19

View File

@@ -119,7 +119,7 @@ static NSOperationQueue *unzipQueue;
NSError *err;
NSData *protoData = [NSData dataWithContentsOfFile:[cacheDir stringByAppendingString:@"/movie.binary"]];
SVGAProtoMovieEntity *protoObject = [SVGAProtoMovieEntity parseFromData:protoData error:&err];
if (!err) {
if (!err && [protoObject isKindOfClass:[SVGAProtoMovieEntity class]]) {
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:cacheDir];
[videoItem resetImagesWithProtoObject:protoObject];
[videoItem resetSpritesWithProtoObject:protoObject];
@@ -191,7 +191,7 @@ static NSOperationQueue *unzipQueue;
NSData *inflateData = [self zlibInflate:data];
NSError *err;
SVGAProtoMovieEntity *protoObject = [SVGAProtoMovieEntity parseFromData:inflateData error:&err];
if (!err) {
if (!err && [protoObject isKindOfClass:[SVGAProtoMovieEntity class]]) {
SVGAVideoEntity *videoItem = [[SVGAVideoEntity alloc] initWithProtoObject:protoObject cacheDir:@""];
[videoItem resetImagesWithProtoObject:protoObject];
[videoItem resetSpritesWithProtoObject:protoObject];