Why is this code causing my program to crash at runtime?
FreeHeap(m_string);
m_string = AllocHeap(len(str) + 1);
*(wstring)m_string = str;
Note: I have m_string declared as heap.
Lewis
Hmmmm Ive just debuged it and if i put a break point just before that method. This appears in the debug context...
Starting debug session...
Loading DLL: ntdll.dll
Loading DLL: C:\WINDOWS\system32\kernel32.dll
Loading DLL: C:\WINDOWS\system32\USER32.DLL
Loading DLL: C:\WINDOWS\system32\GDI32.dll
Loading DLL: C:\WINDOWS\system32\IMM32.DLL
Loading DLL: C:\WINDOWS\system32\ADVAPI32.dll
Loading DLL: C:\WINDOWS\system32\RPCRT4.dll
Loading DLL: C:\WINDOWS\system32\LPK.DLL
Loading DLL: C:\WINDOWS\system32\USP10.dll
Loading DLL: C:\WINDOWS\system32\msvcrt.dll
User breakpoint encountered: Address 0x00404087
HEAP[CString.exe]:
Invalid Address specified to RtlFreeHeap( 00860000, 0012FFB8 )
User breakpoint encountered: Address 0x7C901230
It was the invalid address specified for RtlFreeHeap that caught my eye. Does this mean anything?
Lewis
If you allocate memory for a Unicode string, you need to allocate at least 2 * (length + 1) bytes. Remember, each character is 2 bytes (at least; with UTF-32, each character is 4 bytes).
Yep. Aurora uses UTF-16 so the *2 is important.