[Libreoffice-commits] core.git: odk/source
Simon Danner
danner.simon at gmail.com
Sun Aug 3 00:40:31 PDT 2014
odk/source/unoapploader/win/unoapploader.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
New commits:
commit c2cd1132ef7974387f403dabeeec8fba54c7d041
Author: Simon Danner <danner.simon at gmail.com>
Date: Sat Aug 2 22:55:46 2014 +0200
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 at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/odk/source/unoapploader/win/unoapploader.c b/odk/source/unoapploader/win/unoapploader.c
index 830a38d..ab95399 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();
More information about the Libreoffice-commits
mailing list