diff --git a/src/ios/CDVAssetLibraryFilesystem.m b/src/ios/CDVAssetLibraryFilesystem.m index 8486b7be1..35700dc9f 100644 --- a/src/ios/CDVAssetLibraryFilesystem.m +++ b/src/ios/CDVAssetLibraryFilesystem.m @@ -195,7 +195,7 @@ - (void)readFileAtURL:(CDVFilesystemURL *)localURL start:(NSInteger)start end:(N // We have the asset! Get the data and send it off. ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation]; NSUInteger size = (end > start) ? (end - start) : [assetRepresentation size]; - Byte* buffer = (Byte*)malloc(size); + Byte* buffer = (Byte*)calloc(1, size); NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:start length:size error:nil]; NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES]; NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);