I was debugging a program today which uses the Infrared port and found a crash in X86 Debug mode (in the emu) which I traced to these two lines of code someone wrote:
portName = _T("DUMMY_PORT_NAME");
wsprintf(portName,_T("COM%d:"),portNumber);
Now my few thought was "Ah - that's a bug, portName should be a TCHAR array, not a pointer to some static data".
But then I thought about it further, and thought "Well DUMMY_PORT_NAME is certainly a long enough buffer, why should it crash?". portNumber is 1.
The other weird thing is the exception happens nowhere near any code!
Exception 00e Thread=81d18000 Proc=c1d8afca
AKY=00000801 PC=01fcad53 ESP=1816f3f4 EA=00015464
EAX = 00015464 EBX = 80200043
ECX = 00000043 EDX = 00000000
ESI = 1816F890 EDI = 00000008
EIP = 01FCAD53 ESP = 1816F3F4
EBP = 1816F3FC EFL = 00003217 CS = 0019
DS = 0040 ES = 0040 SS = 0021 FS = 0060
GS = 0000 OV=0 UP=0 EI=1 PL=0 ZR=0 AC=1
PE=1 CY=1
Any ideas? This one's got me puzzled...
portName = _T("DUMMY_PORT_NAME");
wsprintf(portName,_T("COM%d:"),portNumber);
Now my few thought was "Ah - that's a bug, portName should be a TCHAR array, not a pointer to some static data".
But then I thought about it further, and thought "Well DUMMY_PORT_NAME is certainly a long enough buffer, why should it crash?". portNumber is 1.
The other weird thing is the exception happens nowhere near any code!
Exception 00e Thread=81d18000 Proc=c1d8afca
AKY=00000801 PC=01fcad53 ESP=1816f3f4 EA=00015464
EAX = 00015464 EBX = 80200043
ECX = 00000043 EDX = 00000000
ESI = 1816F890 EDI = 00000008
EIP = 01FCAD53 ESP = 1816F3F4
EBP = 1816F3FC EFL = 00003217 CS = 0019
DS = 0040 ES = 0040 SS = 0021 FS = 0060
GS = 0000 OV=0 UP=0 EI=1 PL=0 ZR=0 AC=1
PE=1 CY=1
Any ideas? This one's got me puzzled...