I realize that its the program from my encryption function.
I've wronly assigned the pCipherSink pointer to NULL. Oops... my problem.int myCrypt::encryption(unsigned char* msg,
unsigned int msglen,
unsigned char* cipherBlock,
unsigned int cipherSize)
{
// Create Array Sink
ArraySink *pCipherSink = new ArraySink((byte*)cipherBlock, MAX_ENCRYPT_BLOCK_SIZE);
if(pCipherSink == NULL)
{
printf("Cannot allocate memory for ArraySink\n");
return 0; // zero or -1
}
DefaultEncryptorWithMAC encryptor(m_key, pCipherSink);
// Encrypt the msg block encryptor.Put((byte*)msg, msglen); encryptor.MessageEnd();
// Read data from the sink int rtnCipherSize = pCipherSink->TotalPutLength();
// Delete encryptor and sink pCipherSink = NULL; delete pCipherSink; return rtnCipherSize; }
Then it goes to another program, in the encryptBlock function,
before the program calls the *delete*. it assigns a NULL value to the "to-be deleted" pointer. Thus, the program deletes a NULL pointer, instead of a pointer which points to some newly created memory.
I think that's the reason.
And then, I've tried to takeout the NULL value assignment.
.......
// Delete encryptor and sink
//pCipherSink = NULL;
delete pCipherSink;
return rtnCipherSize;
}However there is an error from smartptr.h. (from cryptopp again). From what I saw in ddd ( the debugger)
Program received singal SIGSEGV, Segmentation fault. 0x0805518c in ~member_ptr (this=0x4398c088) at smartptr.h:49
which is this line ...
template <class T> member_ptr<T>::~memptr_ptr() {delete m_p};Could you mind give me some suggestions what I should do next? Thank you very much.
-tikviva
