I have declared double pointer like this
UInt8 **contentKeyCtx;
This variable is sent as argument to a function Inside the function there is local variable
UInt8 *localckc = NULL;
localckc = calloc(1, localckcSize);
Then there is some array of values assigned to localckc
When i try to do this
*contentKeyCtx = localckc;
I got Segmentation Fault
What i am doing wrong? Main function
int main (int argc, char *argv[])
{
OSStatus result; // SInt32
UInt8 *inBuff, *outBuff;
UInt32 inBuffSize, outBuffSize;
UInt8 **contentKeyCtx = calloc(1, sizeof(UInt8**));
UInt32 *contentKeyCtxSize;
FILE *fp;
const UInt8 *assetId = {0x1b, 0xf7, 0xf5, 0x3f, 0x5d, 0x5d, 0x5a, 0x1f};// what is this?
inBuff=calloc(1,INBUFFSIZE);
outBuff=calloc(1,OUTBUFFSIZE);
inBuffSize = fread(inBuff, sizeof(UInt8), INBUFFSIZE, fp);
fclose(fp);
// IK we have some data. Now what?
result = SKDServerGenCKC(inBuff, inBuffSize, assetId, contentKeyCtx, contentKeyCtxSize);
free(inBuff);
free(outBuff);
printf("Result is %d\n", result );
return 0;
}
Actual function implementation
OSStatus SKDServerGenCKC(
const UInt8 *serverPlaybackCtx,
UInt32 serverPlaybackCtxSize,
const UInt8 *assetId,
UInt8 **contentKeyCtx,
UInt32 *contentKeyCtxSize)
{
UInt8 *localckc = NULL;
UInt32 localckcSize = 0;
PS_RequireAction(ckcContainer != NULL, return kDRMSKDServerParamErr;)
PS_RequireAction(contentKeyCtx != NULL, return kDRMSKDServerParamErr;)
PS_RequireAction(contentKeyCtxSize != NULL, return kDRMSKDServerParamErr;)
...
localckc = calloc(1, localckcSize);
status = SKDServerWriteBytes(
&ckcContainer->parser.currentOffset, PS_AES128_IV_SZ,
ckcContainer->aesKeyIV, localckcSize, localckc);
...
*contentKeyCtx = localckc;
}
*contentKeyCtx = localckc;you meantcontentKeyCtx = &localckc;.*can only be used when you haveUint8 **contentKeyCtx initialized...*contentKeyCtx = ...) would be just guessing.main, John answered before I could have. Of course, he got it right. This entire comment conversation would have been unnecessary had you posted an MCV example. I'm not wanting you to interpret this as being mean-spirited. On the contrary, I want to be a good helper and encourage you to be more diligent in posting good questions, those that are more likely to get upvoted. Have a blessed day.