eina_file_win32: close handler in case of error
authorVyacheslav Reutskiy <v.reutskiy@samsung.com>
Wed, 23 Nov 2016 13:43:40 +0000 (15:43 +0200)
committerWonki Kim <wonki_.kim@samsung.com>
Mon, 2 Jan 2017 07:23:55 +0000 (16:23 +0900)
Func _eina_file_win32_first_file try to find the first file in directory
but if any file not found the file handler stay open, and func will
return error. But in this case while handle is open impossible to do
any actions. For example call eina_file_ls for empty folder, func will
return error and fold folder open. And if we try to remove this folder
Windows only mark it to delete, and remove it after the process is
complete.

Solution: close handler in error case.

Change-Id: I178d99e2a29ef8021b35ec1e17068021363ac1f4
Signed-off-by: Vyacheslav Reutskiy <v.reutskiy@samsung.com>
src/lib/eina/eina_file_win32.c

index 2df5956..54b5d90 100644 (file)
@@ -160,7 +160,10 @@ _eina_file_win32_first_file(const char *dir, WIN32_FIND_DATA *fd)
            ((fd->cFileName[1] == '.') && (fd->cFileName[2] == '\0'))))
      {
         if (!FindNextFile(h, fd))
-          return INVALID_HANDLE_VALUE;
+          {
+             FindClose(h);
+             return INVALID_HANDLE_VALUE;
+          }
      }
 
    return h;