From a1a2d8417fce1bd1ec0c98240b644c5f150db24d Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Sun, 11 Jan 2015 13:16:12 -0500 Subject: Fix memory leak: WT_TABLE.nindices wasn't being incremented in all cases, reference #1474. --- src/schema/schema_open.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/schema/schema_open.c') diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 81447b173ae..0948c9e04aa 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -312,7 +312,8 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, memmove(&table->indices[i + 1], &table->indices[i], (table->nindices - i) * sizeof(WT_INDEX *)); table->indices[i] = NULL; - ++table->nindices; + if (!match) + ++table->nindices; } if (!match) @@ -327,6 +328,8 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, table->indices[i] = idx; idx = NULL; + + ++table->nindices; } /* If we were looking for a single index, we're done. */ -- cgit v1.2.1 From 7804e643f73e48ea3afba42d310d72db48aefa6a Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Tue, 13 Jan 2015 04:30:43 +1100 Subject: Tweak the logic around incrementing nindices and add a comment for next time we need to debug this. No real change. refs #1474 --- src/schema/schema_open.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/schema/schema_open.c') diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c index 0948c9e04aa..d613ced00aa 100644 --- a/src/schema/schema_open.c +++ b/src/schema/schema_open.c @@ -312,8 +312,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, memmove(&table->indices[i + 1], &table->indices[i], (table->nindices - i) * sizeof(WT_INDEX *)); table->indices[i] = NULL; - if (!match) - ++table->nindices; + ++table->nindices; } if (!match) @@ -329,7 +328,12 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, table->indices[i] = idx; idx = NULL; - ++table->nindices; + /* + * If the slot is bigger than anything else we've seen, + * bump the number of indices. + */ + if (i >= table->nindices) + table->nindices = i + 1; } /* If we were looking for a single index, we're done. */ -- cgit v1.2.1