Commit ac8e5733 authored by Rusty Russell's avatar Rusty Russell

tdb2: close memory leak in traverse.

parent 71c1a95f
...@@ -26,15 +26,19 @@ static int64_t traverse(struct tdb_context *tdb, int ltype, ...@@ -26,15 +26,19 @@ static int64_t traverse(struct tdb_context *tdb, int ltype,
struct tdb_data k, d; struct tdb_data k, d;
int64_t count = 0; int64_t count = 0;
k.dptr = NULL;
for (ret = first_in_hash(tdb, ltype, &tinfo, &k, &d.dsize); for (ret = first_in_hash(tdb, ltype, &tinfo, &k, &d.dsize);
ret == 1; ret == 1;
ret = next_in_hash(tdb, ltype, &tinfo, &k, &d.dsize)) { ret = next_in_hash(tdb, ltype, &tinfo, &k, &d.dsize)) {
d.dptr = k.dptr + k.dsize; d.dptr = k.dptr + k.dsize;
count++; count++;
if (fn && fn(tdb, k, d, p)) if (fn && fn(tdb, k, d, p)) {
free(k.dptr);
break; break;
} }
free(k.dptr);
}
if (ret < 0) if (ret < 0)
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment