Kaydet (Commit) c2cd1132 authored tarafından Simon Danner's avatar Simon Danner Kaydeden (comit) David Tardon

odk/unoapploader/win: fix cppcheck error

 Common realloc mistake: 'buf' nulled but not freed upon failure

Change-Id: I8a793e0267c1bb7086bb4f13aabb374faa94f7a4
Reviewed-on: https://gerrit.libreoffice.org/10702Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst e2b0e757
......@@ -135,6 +135,7 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startinfo, &procinfo);
if (ret != 0) {
char * buf = NULL;
char * tmp;
size_t n = 1000;
size_t k = 0;
DWORD exitcode;
......@@ -143,13 +144,15 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
CloseHandle(procinfo.hThread);
for (;;) {
DWORD m;
buf = realloc(buf, n);
if (buf == NULL) {
tmp = realloc(buf, n);
if (tmp == NULL) {
free(buf);
writeError(
"Error: out of memory reading unoinfo output!\n");
closeErrorFile();
return 1;
}
buf = tmp;
if (!ReadFile(stdoutRead, buf + k, n - k, &m, NULL))
{
DWORD err = GetLastError();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment