The calling code
pTempBuf = HTTP_packToGen(&http_headerContent->HTTP, pTempBuf, bufTemp, sizeof(bufTemp), x, "HTTP/1.1 %d %s\r\n", http_htmlheaderStatus[x].code, http_htmlheaderStatus[x].string);
the called code is
char* HTTP_packToGen(char **hdrContent, char *pTempBuf, char *bufTemp, int szBufTmp, int x, char *message, ...)
{
va_list ap;
char tmpbuf[1024];
int colonPos = 0;
char command[32], data[256];
bool httpGet = FALSE;
memset(tmpbuf, '\0', sizeof(tmpbuf));
va_start(ap, message); // Initialize the va_list.
vsnprintf(tmpbuf, sizeof(tmpbuf), message, ap);
if (strstr(tmpbuf, ":") != NULL)
{
httpGet = TRUE;
}
sscanf(tmpbuf, "%s %{%512s}", command, data);
//MessageBoxA(0, data, command, MB_OK);
pTempBuf += _snprintf(pTempBuf, szBufTmp - (strlen(bufTemp) - 1), "%s%s%s", command, httpGet ? ": ":" ", data);
*hdrContent = (char*)calloc((strlen(command)+strlen(data)+sizeof(bool))+4, sizeof(char));
_snprintf(*hdrContent, (strlen(command)+strlen(data)+sizeof(bool))+4, "%s %s", command, data);
output("httpGenerate.cpp", "HTTP_packToGen", "%s", *hdrContent);
return pTempBuf;
}
I have been testing other parts of the code and the
if (hdrContent == 0)
{
/* Error - invalid argument */
}
else if (*hdrContent != 0)
{
free(*hdrContent);
}
kept causing crashes where Visual Studio would show me some code written by microsoft some output.c file and it didn't really help me work out what was causing the issue so I removed the tests and the free(... call