今天调试代码,发现一个崩溃问题,居然是VS的运行库上的。。求解!
贴下大概源码:
tidtable.c文件中的_getptd_noexit函数有如下语句#ifdef _DEBUG
        extern void * __cdecl _calloc_dbg_impl(size_t, size_t, int, const char *, int, int *);
        if ((ptd = _calloc_dbg_impl(1, sizeof(struct _tiddata), _CRT_BLOCK, __FILE__, __LINE__, NULL)) != NULL) {
#else  /* _DEBUG */
        if ((ptd = _calloc_crt(1, sizeof(struct _tiddata))) != NULL) {
#endif  /* _DEBUG */
注意:_calloc_dbg_impl调用的最后一个参数传递了一个NULL指针。而_calloc_dbg_impl函数会调用_nh_malloc_dbg_impl(nSize, _newmode, nBlockUse, szFileName, nLine, errno_tmp);
_nh_malloc_dbg_impl函数会调用_heap_alloc_dbg_impl(nSize, nBlockUse, szFileName, nLine, errno_tmp);
此时errno_tmp是一个空指针。
问题出现在_heap_alloc_dbg_impl函数中有如下一段代码:if (pHead == NULL)
{
    *errno_tmp = ENOMEM;
    RTCCALLBACK(_RTC_FuncCheckSet_hook,(1));
}
当pHead为空时,根本没判断errno_tmp指针是否有效,就直接赋值。
不知道大家有没有碰到过此问题,又是怎么解决的??????????