I have function that allocates memory for char* c
variable and later frees it. Got error while debug:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Error!
HEAP CORRUPTION DETECTED: after Normal block (#95) at 0x0130BE00.
CRT detected that the application wrote to memory after end of heap buffer.
What I do wrong?
void logHex(char* value, int len, int level)
{
if (LogHnd)
{
char* c = (char*)calloc(len * 3, 1);
for (int i = 0; i < len; i++)
{
sprintf(c, "%s%02X ",c,value[i]);
}
LogHnd(c, level);
free(c);
}
}