From a1fd4b1a03d6f0af38fd1e1d9cc250f446bb0483 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 23 Jun 2014 10:18:26 +0000 Subject: [PATCH] * dcrt0.cc (insert_file): Fix resource leaks (CIDs 59987, 59988). --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/dcrt0.cc | 3 +++ 2 files changed, 7 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1f63017a1..28870e529 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2014-06-23 Corinna Vinschen + + * dcrt0.cc (insert_file): Fix resource leaks (CIDs 59987, 59988). + 2014-06-23 Corinna Vinschen * ldap.cc (CYG_LDAP_TIMEOUT): Set to 5 secs. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index f72cbb0be..6e75ccee4 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -115,6 +115,7 @@ insert_file (char *name, char *&cmd) size = GetFileSize (f, NULL); if (size == 0xFFFFFFFF) { + CloseHandle (f); debug_printf ("couldn't get file size for '%s', %E", name); return false; } @@ -123,6 +124,7 @@ insert_file (char *name, char *&cmd) char *tmp = (char *) malloc (new_size); if (!tmp) { + CloseHandle (f); debug_printf ("malloc failed, %E"); return false; } @@ -134,6 +136,7 @@ insert_file (char *name, char *&cmd) CloseHandle (f); if (!rf_result || (rf_read != size)) { + free (tmp); debug_printf ("ReadFile failed, %E"); return false; }