1

当我的应用程序运行时,我遇到了一个异常,堆栈如下:

堆栈文本:

WARNING: Stack unwind information not available. Following frames may be wrong.
10f3dda0 7c96b3e5 0ab65a08 000000a4 07dd0000 ntdll!DbgBreakPoint
10f3dfc8 7c98fb98 07dd0000 50000161 000000a4 ntdll!LdrAlternateResourcesEnabled+0x2ca6
10f3e04c 7c96b244 07dd0000 50000161 000000a4 ntdll!RtlpNtMakeTemporaryKey+0x749c
10f3e27c 7c939c0c 07dd0000 40000060 000000a4 ntdll!LdrAlternateResourcesEnabled+0x2b05
10f3e4b0 07b1e04e 07dd0000 40000060 000000a4 ntdll!RtlpUnWaitCriticalSection+0xad
10f3e4cc 07aef6a6 000000a4 d14f13ce 10f3e684 Camera!_heap_alloc_base+0x5e [f:\dd\vctools\crt_bld\self_x86\crt\src\malloc.c @ 105]
10f3e514 07aef42f 00000080 00000001 00000000 Camera!_heap_alloc_dbg_impl+0x1f6 [f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c @ 427]
10f3e534 07aef3cc 00000080 00000000 00000001 Camera!_nh_malloc_dbg_impl+0x1f [f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c @ 239]
10f3e55c 07aef351 00000080 00000000 00000001 Camera!_nh_malloc_dbg+0x2c [f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c @ 296]
10f3e57c 07a0e015 00000080 00000001 00000000 Camera!_malloc_dbg+0x21 [f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c @ 160]
10f3e598 079e68e1 00000080 10f3e76c 00000003 Camera!operator new+0x15 [f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmem.cpp @ 347]
10f3e684 079e5fee 00000080 00000000 10f3e870 Camera!std::_Allocate<char>+0x61 [c:\program files\microsoft visual studio 9.0\vc\include\xmemory @ 43]
10f3e76c 079e5dd7 00000080 d14f1e5a 10f3e96c Camera!std::allocator<char>::allocate+0x2e [c:\program files\microsoft visual studio 9.0\vc\include\xmemory @ 145]
10f3e880 079e5ac3 0000007b 00000000 10f3ea60 Camera!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Copy+0xc7 [c:\program files\microsoft visual studio 9.0\vc\include\xstring @ 2093]
10f3e96c 079e4d1c 0000007b 00000000 10f3eb50 Camera!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Grow+0x53 [c:\program files\microsoft visual studio 9.0\vc\include\xstring @ 2123]
10f3ea60 079e3e55 10f3ec48 00000000 ffffffff Camera!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::assign+0x8c [c:\program files\microsoft visual studio 9.0\vc\include\xstring @ 1055]
10f3eb5c 079fd484 10f3ec48 d14f1a52 10f3ee94 Camera!std::basic_string<char,std::char_traits<char>,std::allocator<char> >::basic_string<char,std::char_traits<char>,std::allocator<char> >+0x75 [c:\program files\microsoft visual studio 9.0\vc\include\xstring @ 724]
10f3ec88 079fd7a9 10f3ee60 00000000 cccccccc Camera!toLower+0xd4 [e:\tcom\camera\Camera\rtspurl1.cpp @ 61]

我的 tolow 函数如下:

string toLower(string str)
{
  char* chartemp=(char*)malloc(str.length()+1);
  memset(chartemp,0,str.length()+1);
  memcpy(chartemp,str.c_str(),str.length());
  strlwr(chartemp);
  string lpUrl=chartemp;
  free(chartemp);
  return lpUrl;
}

我不清楚为什么“return lpUrl”时会发生异常。

4

1 回答 1

3

尝试

string toLower(string str)
{
    for (size_t i =0; i<str.size(); ++i)
        str[i] = std::tolower(str[i]);
    return str;
}

我不知道您对线程错误的引用,因为您没有显示任何相关信息。

更新在这里查看现场演示:http: //liveworkspace.org/code/1d8b31ff73e2c2c9263ff5299dd4b7cb

于 2012-09-18T11:35:02.833 回答