mdbx: remove created file if mdbx_env_copy() failed.

Change-Id: Ie47981b6031c6e7099a5d49f6cd7338ab2c1e040
This commit is contained in:
Leo Yuriev 2018-06-30 14:25:43 +03:00
parent 797bcf9aca
commit e57d4bbb00

View File

@ -10565,15 +10565,17 @@ int __cold mdbx_env_copy(MDBX_env *env, const char *dest_path, unsigned flags) {
rc = mdbx_env_copy2fd(env, newfd, flags);
}
if (dxb_pathname != dest_path)
free(dxb_pathname);
if (newfd != INVALID_HANDLE_VALUE) {
int err = mdbx_closefile(newfd);
if (rc == MDBX_SUCCESS && err != rc)
rc = err;
if (rc != MDBX_SUCCESS)
(void)mdbx_removefile(dxb_pathname);
}
if (dxb_pathname != dest_path)
free(dxb_pathname);
return rc;
}