summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-10-14 10:17:00 +0200
committerTom Hacohen <tom@stosb.com>2015-10-14 09:46:59 +0100
commitb48f0afc731bff78e060c780e0ddc02554ae1ba9 (patch)
treed25c834a05b05324f16a36bac94e4dd4cd336471
parent17f6e75c11e4bb2fce977a5d1c1b7d4223d0796a (diff)
Eina: fix memory leak in eina_file_open()
@fix
-rw-r--r--src/lib/eina/eina_file_win32.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/lib/eina/eina_file_win32.c b/src/lib/eina/eina_file_win32.c
index a1371d73f7..2df5956420 100644
--- a/src/lib/eina/eina_file_win32.c
+++ b/src/lib/eina/eina_file_win32.c
@@ -733,30 +733,16 @@ eina_file_open(const char *path, Eina_Bool shared)
733 733
734 if (handle == INVALID_HANDLE_VALUE) 734 if (handle == INVALID_HANDLE_VALUE)
735 { 735 {
736 LPVOID lpMsgBuf; 736 char *msg;
737 737
738 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 738 msg = evil_last_error_get();
739 FORMAT_MESSAGE_FROM_SYSTEM | 739 if (msg)
740 FORMAT_MESSAGE_IGNORE_INSERTS,
741 NULL,
742 GetLastError(),
743 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
744 (LPTSTR) &lpMsgBuf,
745 0, NULL);
746
747 switch (GetLastError())
748 { 740 {
749 case ERROR_FILE_NOT_FOUND: 741 WRN("eina_file_open() failed with file %s: %s", filename, msg);
750 WRN("Could not open file [%s].", filename); 742 free(msg);
751 free(filename);
752 return NULL;
753 case ERROR_PATH_NOT_FOUND:
754 WRN("Could not find file path [%s].", filename);
755 free(filename);
756 return NULL;
757 default:
758 goto free_file;
759 } 743 }
744 else
745 goto free_file;
760 } 746 }
761 747
762 if (!GetFileAttributesEx(filename, GetFileExInfoStandard, &fad)) 748 if (!GetFileAttributesEx(filename, GetFileExInfoStandard, &fad))