在下面的方法中运行会弹出0x00007FF6F1215BAD 处有未经处理的异常(在 YANG Auto Notice.exe 中): 堆栈 Cookie 检测代码检测到基于堆栈的缓冲区溢出。在debug运行没有报错,转release报错,我要如何解决
void CYANGRemindDlg::netlist()
{
// TODO: 在此添加控件通知处理程序代码
// TODO: 在此添加控件通知处理程序代码
CInternetSession session(_T("HttpClient"));
TCHAR* url = _T("https://v1.jinrishici.com/shuqing/shanggan");
CHttpFile* pfile = (CHttpFile*)session.OpenURL(url);
DWORD dwStatusCode;
pfile->QueryInfoStatusCode(dwStatusCode);
if (dwStatusCode == HTTP_STATUS_OK)
{
CString content4;
CString data;
while (pfile->ReadString(data))
{
content4 += data;
}
char* pch;
pch = new char[content4.GetLength() * sizeof(TCHAR) + 1];
memcpy(pch, content4, content4.GetLength() * sizeof(TCHAR));
content4 = UTF8ToUnicode(pch);//转换编码,不然就乱码了
CString str3 = content4;
Json::Reader reader23;
Json::Value root23;
CString temp23;
CString temp223;
CString temp323;
USES_CONVERSION;
char* cJson1 = T2A(str3.GetBuffer(0));
str3.ReleaseBuffer();
if (reader23.parse(cJson1, root23)) {
temp23 = root23["content"].asCString();
temp223 = root23["origin"].asCString();
temp323 = root23["author"].asCString();
}
temp223 = temp223 + " 作者:" + temp323;
num2 = temp23;
AfxGetApp()->WriteProfileString(_T("Settings"), _T("LocalRecPath2"), num2);//_localRecPath就是要保存的信息,Settings为注册表子键,LocalRecPath即子键的键值名
num = temp223;
AfxGetApp()->WriteProfileString(_T("Settings"), _T("LocalRecPath"), num);//_localRecPath就是要保存的信息,Settings为注册表子键,LocalRecPath即子键的键值名
}
pfile->Close();
delete pfile;
session.Close();
//char* str = "content春如旧。人空瘦。泪痕红浥鲛绡透。";
// "origin" : "钗头凤·红酥手",
// "author" : "陆游",
// "category" : "古诗文-抒情-伤感";
TZ();
}
检查发现引发错误的代码是
char* cJson1 = T2A(str3.GetBuffer(0));
str3.ReleaseBuffer();
if (reader23.parse(cJson1, root23)) {
temp23 = root23["content"].asCString();
temp223 = root23["origin"].asCString();
temp323 = root23["author"].asCString();
}