fix: leak in Response class

This commit is contained in:
Talyx
2022-02-18 18:12:01 +03:00
parent 28c86e5e43
commit 1519914e97
5 changed files with 19 additions and 7 deletions

View File

@@ -99,7 +99,9 @@ std::string CgiHandle::executeCgi()
FILE *fOt = tmpfile();
long fdin = fileno(fIn);
long fdOut = fileno(fOt);
write(fdin, _request.getBody()->data(), _request.getBody()->size());
if (_request.getBody() != NULL)
write(fdin, _request.getBody()->data(), _request.getBody()->size());
lseek(fdin, 0, SEEK_SET);
pid = fork();
if (pid == -1)
@@ -151,7 +153,7 @@ void CgiHandle::initEnvVariables()
_variable["AUTH TYPE"] = it->second;
else
_variable["AUTH TYPE"] = "";
_variable["CONTENT_LENGTH"] = toString(_request.getBody()->size());
_variable["CONTENT_LENGTH"] = (_request.getBody() == NULL) ? "0" : toString(_request.getBody()->size());
it = _request.getClientFields().find("content-type");
_variable["CONTENT_TYPE"] = "";
_variable["GATEWAY_INTERFACE"] = std::string("CGI/1.1");