Hole corruption Detected, where can I remove dynamic memory?


I keep getting this error but I can't figure out when I can delete the dynamic memory for the variables: upSizedPlaintext, upsizedKey, upsizedCiphertext, or upsizedKeyD?

Since I am doing this for an assignment, I have to use BOOST tests and in the test that the lecturer will use, he will delete encryptedText and decrypted in the BOOST test. But I can't manage to find out where I can delete the variables from above. Any ideas and any help is greatly appreciated?

Also, I HAVE to use C-style strings not C++ strings.

As you are returning pointers to new memory from encrypt and decrypt, the code calling those functions becomes responsible for calling delete[] on the pointers they receive.

Not a very good interface, and one reason why we like to use std::string in C++ code!

The usual source of heap corruption in C code is to forget the nul terminator for strings and allocate strlen(s) bytes instead of strlen(s) + 1 bytes. I believe you do that in several places.