_free_base“读取寄存器值时出错”

时间:2014-09-09 19:27:18

标签: c++ encryption runtime-error crypto++

我的测试应用程序中有一些代码:

char* buff = new char[0];
f_hStream.read(buff, size);
string cut_header = zCrypto::from_base64( string(buff, size) );

if ( cut_header.length() == 0 ) break;

const char* dec = zCrypto::decrypt( cut_header );
printf( "Header >> %s\n", dec );
vector<string> header = split(string(dec), ';');

decrypt功能&gt;

const char* zCrypto::decrypt(const std::string& str_in) {
    const string key = zCrypto::from_base64("<base_64line_here>");
    const string iv = zCrypto::from_base64("<base_64line_here>");

    std::string str_out;
    CryptoPP::CBC_Mode<CryptoPP::Rijndael>::Decryption decryption((byte*)key.c_str(), key.length(), (byte*)iv.c_str());

    CryptoPP::StringSource encryptor(str_in, true,
        new CryptoPP::StreamTransformationFilter(decryption,
            new CryptoPP::StringSink(str_out)
        )
    );

    return str_out.data();
}

我在线上获得调试器错误 const char * dec = zCrypto :: decrypt(cut_header); ,如果我试图在没有 MVS 调试器的情况下启动应用程序,他只是崩溃 - Application has stopped working...

P.S。我无法从 / MT 更改Code Generation - Runtime Library,我的应用编译中的cryptopp函数只会在此类型中出现错误。

解密也很好,我做错了什么?

UPDATE:

我改变了

const char* zCrypto::decrypt(const std::string& str_in) {

string zCrypto::decrypt(const std::string& str_in) {

char* buff = new char[0];
const char* dec = zCrypto::decrypt( cut_header );

char* buff = new char[size];
string dec = zCrypto::decrypt( cut_header );

我仍然收到错误。

1 个答案:

答案 0 :(得分:1)

这条线听起来不对。

char* buff = new char[0];

您可能需要:

char* buff = new char[size];