Check return value of malloc

fixes #27

//FREEBIE
pull/1/head
Ronny 9 years ago committed by Michael Kirk
parent 91fcd01632
commit 556dca6502

@ -111,6 +111,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,
@ -189,6 +194,11 @@
// decrypt
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,

Loading…
Cancel
Save