diff options
author | Keith Bostic <keith@wiredtiger.com> | 2013-11-15 20:10:01 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2013-11-15 20:10:01 -0500 |
commit | d4a7201badda8758f5a35d25926a980dd5260d31 (patch) | |
tree | c4e5397049c49f1f10e3683521cd4e0fa0d27c19 | |
parent | cc7ea38beec8f6154fd21a76af97d2144206a019 (diff) | |
download | mongo-d4a7201badda8758f5a35d25926a980dd5260d31.tar.gz |
Coverity: Resource leak (RESOURCE_LEAK)
6. leaked_storage: Variable "from_path" going out of scope leaks the
storage it points to.
Don't leak memory if the second __wt_filename() call fails.
-rw-r--r-- | src/os_posix/os_rename.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/os_posix/os_rename.c b/src/os_posix/os_rename.c index 94ef1573fb6..78d4a0e8adb 100644 --- a/src/os_posix/os_rename.c +++ b/src/os_posix/os_rename.c @@ -19,10 +19,13 @@ __wt_rename(WT_SESSION_IMPL *session, const char *from, const char *to) WT_VERBOSE_RET(session, fileops, "rename %s to %s", from, to); + from_path = to_path = NULL; + WT_RET(__wt_filename(session, from, &from_path)); - WT_RET(__wt_filename(session, to, &to_path)); + WT_TRET(__wt_filename(session, to, &to_path)); - WT_SYSCALL_RETRY(rename(from_path, to_path), ret); + if (ret == 0) + WT_SYSCALL_RETRY(rename(from_path, to_path), ret); __wt_free(session, from_path); __wt_free(session, to_path); |