Check return value of malloc

fixes #27

//FREEBIE
This commit is contained in:
Ronny 2016-10-03 10:58:49 +02:00 committed by Michael Kirk
parent 91fcd01632
commit 556dca6502

View file

@ -112,6 +112,11 @@
size_t bufferSize = [dataToEncrypt length] + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
if (buffer == NULL) {
DDLogError(@"Failed to allocate memory.");
return nil;
}
size_t bytesEncrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt,
kCCAlgorithmAES128,
@ -190,6 +195,11 @@
size_t bufferSize = [dataToDecrypt length] + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
if (buffer == NULL) {
DDLogError(@"Failed to allocate memory.");
return nil;
}
size_t bytesDecrypted = 0;
CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt,
kCCAlgorithmAES128,