Skip to content

Commit

Permalink
Fix free null pointer bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Aug 25, 2020
1 parent 155da70 commit cf3ae05
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/OpenArkDrv/arkdrv-api/arkdrv-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ bool IoControlDriver(DWORD ctlcode, DWORD op, PVOID inbuf, DWORD inlen, PVOID *o
return false;

*outbuf = NULL;
*outlen = 0;
DWORD wrap_inlen = sizeof(op) + inlen;
PUCHAR wrap_inbuf = (PUCHAR)malloc(wrap_inlen);
if (!wrap_inbuf) return false;
Expand Down Expand Up @@ -115,7 +116,7 @@ bool IoControlDriver(DWORD ctlcode, DWORD op, const std::wstring &indata, std::s
bool ret = IoControlDriver(ctlcode, op, (PVOID)tempdata, tempsize, (PVOID*)&info, &outlen);
if (!ret) return false;
if (outlen) outdata.assign(info, outlen);
free(info);
if (info) free(info);
return true;
}
bool IoControlDriver(DWORD ctlcode, DWORD op, const std::string &indata, std::string &outdata)
Expand All @@ -132,7 +133,7 @@ bool IoControlDriver(DWORD ctlcode, DWORD op, const std::string &indata, std::st
bool ret = IoControlDriver(ctlcode, op, (PVOID)tempdata, tempsize, (PVOID*)&info, &outlen);
if (!ret) return false;
outdata.assign(info, outlen);
free(info);
if (info) free(info);
return true;
}

Expand Down

0 comments on commit cf3ae05

Please sign in to comment.