In your case you do need to destroy:
 1) document
 2) siganture context
 3) key
The order does not matter.

Aleksey

Monica Lau wrote:
Hi Aleksey,
Sorry to keep bothering you. Hopefully, this will be the last time. :-) I have a question about the memory cleanup after generating the Hmac key and signing the xml document. I believe the ordering of the memory cleanup matters because I've tried swapping the ordering, and the program hangs/crashes. Here is the code that doesn't work:
int SignDoc( ...)
{
/* Generate XML Doc */
...
/* Generate Hmac Key (placing the contents of the CreateHmacKey( ) function that you provided here) */
...
/* print signed document to memory */
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
/* cleanup memory */
xmlSecKeyDataDestroy(xmlSecKey_data);
xmlSecKeyDestroy(xmlSecKey);
xmlFree(xmlbuff);


   if(dsigCtx != NULL) {
       xmlSecDSigCtxDestroy(dsigCtx);
   }

if(doc != NULL) {
xmlFreeDoc(doc);
}
}
On the other hand, if I swap the order of the memory clean up steps, then it works great:
/* cleanup memory */
if(dsigCtx != NULL) {
xmlSecDSigCtxDestroy(dsigCtx);
}


if(doc != NULL) {
xmlFreeDoc(doc);
}
xmlFree(xmlbuff);
xmlSecKeyDataDestroy(key_data);
xmlSecKeyDestroy(key);
Question: Is it necessary to call the xmlSecKeyDataDestroy and xmlSecKeyDestroy functions since I am calling xmlSecDSigCtxDestroy? If it is necessary to destory the keys, then is this the correct order?
Thanks for your help again,
Monica


------------------------------------------------------------------------
Do you Yahoo!?
Check out the new Yahoo! Front Page. www.yahoo.com <http://www.yahoo.com>
_______________________________________________
xmlsec mailing list
[EMAIL PROTECTED]
http://www.aleksey.com/mailman/listinfo/xmlsec

Reply via email to