From cd00b3fa5d5637a08368db621bb4e7bd5e83cf09 Mon Sep 17 00:00:00 2001 From: Akinobu Mita Date: Fri, 5 Mar 2010 18:17:24 +0900 Subject: [PATCH] fix memory leak in tokyotyrant-test and tokyocabinet-test --- tokyocabinet-test.c | 4 +++- tokyotyrant-test.c | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/tokyocabinet-test.c b/tokyocabinet-test.c index a628a02..473ac2c 100644 --- a/tokyocabinet-test.c +++ b/tokyocabinet-test.c @@ -110,8 +110,10 @@ static void cursor_db(TCBDB *bdb, unsigned long count) tcbdbcurjump2(cur, "0x"); while ((key = tcbdbcurkey2(cur)) != NULL) { - if (strncmp(key, "0x", 2) != 0) + if (strncmp(key, "0x", 2) != 0) { + free(key); break; + } value = tcbdbcurval2(cur); read_value(value); diff --git a/tokyotyrant-test.c b/tokyotyrant-test.c index d6e6877..7a9d080 100644 --- a/tokyotyrant-test.c +++ b/tokyotyrant-test.c @@ -143,8 +143,10 @@ static void iter_db(TCRDB *rdb, unsigned long count) } while ((key = tcrdbiternext2(rdb)) != NULL) { - if (strncmp(key, "0x", 2) != 0) + if (strncmp(key, "0x", 2) != 0) { + free(key); continue; + } free(key); } } @@ -162,8 +164,10 @@ static void iter_get_db(TCRDB *rdb, unsigned long count) while ((key = tcrdbiternext2(rdb)) != NULL) { char *value; - if (strncmp(key, "0x", 2) != 0) + if (strncmp(key, "0x", 2) != 0) { + free(key); continue; + } value = tcrdbget2(rdb, key); read_value(value); @@ -185,9 +189,10 @@ static void iter_get3_db(TCRDB *rdb, unsigned long count) } while ((key = tcrdbiternext2(rdb)) != NULL) { - if (strncmp(key, "0x", 2) != 0) + if (strncmp(key, "0x", 2) != 0) { + free(key); continue; - + } tcmapput2(map, key, ""); free(key);