我正在将C++中的一个小代码重新定义为加密和解密消息,为此我使用了small。
由于文本的长度不是恒定的,所以我必须使用动态内存,并且为了处理内存中分配的数据的安全性,我使用了sodium_malloc函数。
在编写代码之后,我测试了它,但是在我用sodium_malloc分配内存的时候,它为我生成了一个异常,下面是一个摘录:
int main()
{
unsigned char* text;
text = (unsigned char*)sodium_malloc(sizeof(unsigned char) * (12)); // hello worold --> lenth: 11 + 1 ('\0')
sodium_free(text);
system("pause");
return 0;
}它为我生成了这个异常:
Unhandled Exception in 0x00007FFDBE61286E (ucrtbase.dll) in DEF (Console).exe: Exit was requested from the program causing an unrecoverable error.发布于 2022-08-27 09:47:05
https://stackoverflow.com/questions/73509808
复制相似问题