diff options
author | Simon Danner <danner.simon@gmail.com> | 2014-08-02 22:55:46 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-08-03 07:40:12 +0000 |
commit | c2cd1132ef7974387f403dabeeec8fba54c7d041 (patch) | |
tree | e0c57ea8c970e68b5966dac19b0fc9014d59e4d0 /odk/source/unoapploader | |
parent | e2b0e7571a8b082a2cb532e34b9770060128452b (diff) |
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/10702
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'odk/source/unoapploader')
-rw-r--r-- | odk/source/unoapploader/win/unoapploader.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/odk/source/unoapploader/win/unoapploader.c b/odk/source/unoapploader/win/unoapploader.c index 830a38df6079..ab953990a07a 100644 --- a/odk/source/unoapploader/win/unoapploader.c +++ b/odk/source/unoapploader/win/unoapploader.c @@ -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(); |