summaryrefslogtreecommitdiff
path: root/src/config/config_collapse.c
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-05-09 11:33:19 -0400
committerKeith Bostic <keith.bostic@mongodb.com>2016-05-09 11:33:19 -0400
commit62fc6016ee2aadde459fa744959f7a55357ce4a6 (patch)
treee3eee079d0520698f6b982f1043a4f53fdab4b0e /src/config/config_collapse.c
parent7153550cce30d15b18aad18765b0a40d9765cbcf (diff)
downloadmongo-62fc6016ee2aadde459fa744959f7a55357ce4a6.tar.gz
WT-2627: Coverity complaints (#2727)
* WT-2627: Coverity complaints Coverity complaint 1354814: error path leaking allocated memory. Initially clear caller's handle in __wt_fopen(). * Coverity 1355027 thinks there's a path to leak memory in: __backup_list_uri_append() calls __wt_metadata_search() calls__wt_turtle_read() calls __metadata_config() calls __wt_config_collapse() which I think should only happen if one of those functions allocates memory and then returns an error, and I don't see it. Change __wt_config_collapse to always clear the caller's memory location, it's good practice. Simplify __metadata_config slightly, we don't need need a local variable into which we store the allocated memory, and there's no error path that might need to free that allocated memory, hope that helps Coverity. * Whitespace, KNF. * Whitespace
Diffstat (limited to 'src/config/config_collapse.c')
-rw-r--r--src/config/config_collapse.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/config/config_collapse.c b/src/config/config_collapse.c
index 27bd6255a0a..591d22284f5 100644
--- a/src/config/config_collapse.c
+++ b/src/config/config_collapse.c
@@ -38,6 +38,8 @@ __wt_config_collapse(
WT_DECL_ITEM(tmp);
WT_DECL_RET;
+ *config_ret = NULL;
+
WT_RET(__wt_scr_alloc(session, 0, &tmp));
WT_ERR(__wt_config_init(session, &cparser, cfg[0]));
@@ -59,6 +61,8 @@ __wt_config_collapse(
WT_ERR(__wt_buf_catfmt(session, tmp, "%.*s=%.*s,",
(int)k.len, k.str, (int)v.len, v.str));
}
+
+ /* We loop until error, and the expected error is WT_NOTFOUND. */
if (ret != WT_NOTFOUND)
goto err;