summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2013-05-31 13:42:19 +1000
committerMichael Cahill <michael.cahill@wiredtiger.com>2013-05-31 13:42:19 +1000
commit061e350dbf3158c8e385b31e0c3841b3847ebc63 (patch)
tree2b104bdaf9cdd4f5718820c4a6a2428fd27495a2
parent4536f166a8bec4ec9fe422b4184ac6010f53680b (diff)
downloadmongo-061e350dbf3158c8e385b31e0c3841b3847ebc63.tar.gz
Fix a leak in the free-on-close list code used for extension-specific config.
-rw-r--r--src/config/config_check.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/config/config_check.c b/src/config/config_check.c
index d81b737a8f4..f7d0788ef0d 100644
--- a/src/config/config_check.c
+++ b/src/config/config_check.c
@@ -11,16 +11,15 @@ static int config_check(
WT_SESSION_IMPL *, const WT_CONFIG_CHECK *, const char *, size_t);
/*
- * __wt_conn_foc_add --
+ * __conn_foc_add --
* Add a new entry into the connection's free-on-close list.
*/
static int
-__wt_conn_foc_add(WT_SESSION_IMPL *session, ...)
+__conn_foc_add(WT_SESSION_IMPL *session, const void *p)
{
WT_CONNECTION_IMPL *conn;
va_list ap;
size_t cnt;
- void *p;
conn = S2C(session);
@@ -38,21 +37,12 @@ __wt_conn_foc_add(WT_SESSION_IMPL *session, ...)
*
* Our caller is expected to be holding any locks we need.
*/
- /* Count the slots. */
- va_start(ap, session);
- for (cnt = 0; va_arg(ap, void *) != NULL; ++cnt)
- ;
- va_end(ap);
-
- if (conn->foc_cnt + cnt >= conn->foc_size) {
- WT_RET(__wt_realloc(session, NULL,
- (conn->foc_size + cnt + 20) * sizeof(void *), &conn->foc));
- conn->foc_size += cnt + 20;
- }
- va_start(ap, session);
- while ((p = va_arg(ap, void *)) != NULL)
- conn->foc[conn->foc_cnt++] = p;
- va_end(ap);
+ if ((conn->foc_cnt + 1) * sizeof(void *) > conn->foc_size)
+ WT_RET(__wt_realloc(session, &conn->foc_size,
+ WT_MAX(20 * sizeof(void *), 2 * conn->foc_size),
+ &conn->foc));
+
+ conn->foc[conn->foc_cnt++] = (void *)p;
return (0);
}
@@ -191,11 +181,14 @@ __wt_configure_method(WT_SESSION_IMPL *session,
/*
* The next time this configuration is updated, we don't want to figure
* out which of these pieces of memory were allocated and will need to
- * be free'd on close, add them to the list now.
+ * be free'd on close, add them all to the free-on-close list now.
*/
- WT_ERR(__wt_conn_foc_add(session,
- entry, entry->base,
- checks, newcheck->name, newcheck->type, newcheck->checks, NULL));
+ WT_ERR(__conn_foc_add(session, entry));
+ WT_ERR(__conn_foc_add(session, entry->base));
+ WT_ERR(__conn_foc_add(session, checks));
+ WT_ERR(__conn_foc_add(session, newcheck->name));
+ WT_ERR(__conn_foc_add(session, newcheck->type));
+ WT_ERR(__conn_foc_add(session, newcheck->checks));
*epp = entry;