Note that there are some explanatory texts on larger screens.

plurals
  1. POCCCrypt Crash (EXC_BAD_ACCESS)
    text
    copied!<p>I am trying to decode some data however when the data is larger than 520,000 (bytes? It's <code>[data length]</code>) my app will crash on debugger on the <code>CCCrypt</code> line, or if detached from debugger it just freezes and doesn't actually crash properly (Spinner keeps going round but app completely freezes).</p> <p>This is my decrypt code:</p> <pre><code>char *key = ENCRYPTION_KEY; NSUInteger dataLength = [data length]; uint8_t unencryptedData[dataLength + kCCKeySizeAES128]; size_t unencryptedLength; CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionECBMode, key, kCCKeySizeAES128, NULL, [data bytes], dataLength, unencryptedData, dataLength, &amp;unencryptedLength); NSData *output = [[NSData alloc] initWithBytes:unencryptedData length:unencryptedLength]; return output; </code></pre> <p>EDIT ----------</p> <p>Following Hejazi's answer below, I now have this, but it still doesn't work :(</p> <pre><code>- (NSData *)decodeSnapDataInBackground:(NSData *)data { char *key = ENCRYPTION_KEY; NSUInteger dataLength = [data length]; uint8_t unencryptedData[dataLength + kCCBlockSizeAES128]; size_t unencryptedLength; size_t unencryptedDataLength = dataLength + kCCBlockSizeAES128; CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionECBMode, key, kCCKeySizeAES128, NULL, [data bytes], dataLength, unencryptedData, unencryptedDataLength, &amp;unencryptedLength); NSData *output = [[NSData alloc] initWithBytes:unencryptedData length:unencryptedLength]; return output; } </code></pre> <p>EDIT 2 -----</p> <p>It seems this problem occurs when I perform the decoding on a background thread. I was using this:</p> <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ </code></pre> <p>When I removed it, it now decodes large blocks of data fine.</p> <p>Why would this be, and is there any way I can get this to work on a background thread?</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload