Eina: fix memory leak in eina_file_open()

@fix
This commit is contained in:
Vincent Torri 2015-10-14 10:17:00 +02:00 committed by Tom Hacohen
parent 8854b9f727
commit d8008f4625
1 changed files with 7 additions and 21 deletions

View File

@ -733,30 +733,16 @@ eina_file_open(const char *path, Eina_Bool shared)
if (handle == INVALID_HANDLE_VALUE)
{
LPVOID lpMsgBuf;
char *msg;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL);
switch (GetLastError())
msg = evil_last_error_get();
if (msg)
{
case ERROR_FILE_NOT_FOUND:
WRN("Could not open file [%s].", filename);
free(filename);
return NULL;
case ERROR_PATH_NOT_FOUND:
WRN("Could not find file path [%s].", filename);
free(filename);
return NULL;
default:
goto free_file;
WRN("eina_file_open() failed with file %s: %s", filename, msg);
free(msg);
}
else
goto free_file;
}
if (!GetFileAttributesEx(filename, GetFileExInfoStandard, &fad))