内存越界两则:
1、BASE64编码,内存计算错误,导致申请的空间不够,
//ASCIItoBASE64
len = pSUPCON_Config_File->mCDATA_Len/3;
if(pSUPCON_Config_File->mCDATA_Len%3)
{
len += 1;
}
len = len * 4 + 1;
pTmpContext = (char *) malloc(len);
memset(pTmpContext,0,len);
Base64_len = Base64_Encode(pSUPCON_Config_File->pCDATA, pSUPCON_Config_File->mCDATA_Len, pTmpContext);
|
原来是len/3*4,导致内存越界
2、多线程网络程序,用了两个线程不安全的函数 gmtime gethostbyname,导致内存越界,提示
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 131081 (LWP 568)]
0x403f8784 in mallopt () from /lib/libc.so.6
阅读(1147) | 评论(0) | 转发(0) |