summaryrefslogtreecommitdiff
path: root/src/os_common/filename.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_common/filename.c')
-rw-r--r--src/os_common/filename.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/os_common/filename.c b/src/os_common/filename.c
index 5aeb64bb51e..d5695f63d91 100644
--- a/src/os_common/filename.c
+++ b/src/os_common/filename.c
@@ -29,6 +29,7 @@ int
__wt_nfilename(
WT_SESSION_IMPL *session, const char *name, size_t namelen, char **path)
{
+ WT_DECL_RET;
size_t len;
char *buf;
@@ -39,16 +40,17 @@ __wt_nfilename(
* the exists API which is used by the test utilities.
*/
if (session == NULL || __wt_absolute_path(name))
- WT_RET(__wt_strndup(session, name, namelen, path));
- else {
- len = strlen(S2C(session)->home) + 1 + namelen + 1;
- WT_RET(__wt_calloc(session, 1, len, &buf));
- snprintf(buf, len, "%s%s%.*s", S2C(session)->home,
- __wt_path_separator(), (int)namelen, name);
- *path = buf;
- }
+ return (__wt_strndup(session, name, namelen, path));
+ len = strlen(S2C(session)->home) + 1 + namelen + 1;
+ WT_RET(__wt_calloc(session, 1, len, &buf));
+ WT_ERR(__wt_snprintf(buf, len, "%s%s%.*s",
+ S2C(session)->home, __wt_path_separator(), (int)namelen, name));
+ *path = buf;
return (0);
+
+err: __wt_free(session, buf);
+ return (ret);
}
/*