diff options
Diffstat (limited to 'Modules/posixmodule.c')
| -rw-r--r-- | Modules/posixmodule.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 931c0d3f3a..80add7da5f 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1640,11 +1640,6 @@ get_target_path(HANDLE hdl, wchar_t **target_path) return FALSE; } - if(!CloseHandle(hdl)) { - PyMem_RawFree(buf); - return FALSE; - } - buf[result_length] = 0; *target_path = buf; @@ -1702,9 +1697,10 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result, return -1; } if (info.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { - if (!win32_get_reparse_tag(hFile, &reparse_tag)) + if (!win32_get_reparse_tag(hFile, &reparse_tag)) { + CloseHandle(hFile); return -1; - + } /* Close the outer open file handle now that we're about to reopen it with different flags. */ if (!CloseHandle(hFile)) @@ -1721,8 +1717,14 @@ win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result, if (hFile2 == INVALID_HANDLE_VALUE) return -1; - if (!get_target_path(hFile2, &target_path)) + if (!get_target_path(hFile2, &target_path)) { + CloseHandle(hFile2); return -1; + } + + if (!CloseHandle(hFile2)) { + return -1; + } code = win32_xstat_impl(target_path, result, FALSE); PyMem_RawFree(target_path); |
