X
X
X-Ray_3D2017-03-12 18:34:47
Qt
X-Ray_3D, 2017-03-12 18:34:47

HEAP CORRUPTION DETECTED?

The code below causes an incorrect termination of the program.
If to call functions on a straight line through if of an error does not arise.
HEAP [MAN2_GUI.exe]: Heap block AT 0000000000395A00 modified AT 000000000039626C the past Requested size bed of 85c
HEAP [MAN2_GUI.exe]: Invalid address specified 'to RtlValidateHeap (0,000,000,000,350,000, 0000000000395A10)
Program: ..._ the GUI-Desktop_Qt_5_8_0_MSVC2015_64bit-the Debug \ the debug \ MAN2_GUI .exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 888
Expression: _CrtIsValidHeapPointer(block)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
Program: ..._GUI-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\debug\MAN2_GUI.exe
HEAP CORRUPTION DETECTED: after Normal block (#1903) at 0x0000000000395A40.
CRT detected that the application wrote to memory after end of heap buffer.
(Press Retry to debug the application)
HEAP[MAN2_GUI.exe]: Heap block at 0000000000395A00 modified at 000000000039626C past requested size of 85c
*.h

enum COMMAND {
        PING,
        ...
        ...
        BUFFER_OVERFLOW = 0xDF,
        WRONG_COMMAND = 0xEF,
    };
signals:
    void U(int ch, float v);
    void ManChannelDetected(int ch);

private:
    void CmdPing();
    void CmdNullFunction();
    typedef void (MyProtocol::*pFunc)();
    pFunc CmdArray[0xFF];

*.cpp
constructor
for (int i = 0; i < 0xFF; ++i) {
    CmdArray[i] = &MyProtocol::CmdNullFunction;
}
CmdArray[PING] = &MyProtocol::CmdPing;
connect(this, &QSerialPort::readyRead, this, &MyProtocol::readyRead);

Slot, use.
void MyProtocol::readyRead()
{
     QMutexLocker locker(&readMutex);
     ...
    (this->*CmdArray[Data[4]])();
     ...
}

"Callbuck"
void MyProtocol::CmdPing()
{
    Channels.append((uint8_t)Data[5]);
    emit ManChannelDetected((uint8_t)Data[5]);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2017-03-12
@maaGames

CmdArray[PING] = &MyProtocol::CmdPing;
Wangyu that PING = 0xff

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question