Permalink
Browse files

tcdb: fix a leak that impacts INCR[BY] / DECR[BY] commands

  • Loading branch information...
1 parent 0cebb6c commit 15c59c65630244e0cbd1b790f0d5fb714b8bf532 @deltheil deltheil committed Apr 4, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 tcdb.c
View
3 tcdb.c
@@ -596,14 +596,15 @@ static int64_t rk_tcdb_add_int(rk_tcdb_t *db, const char *kbuf, int ksiz, int64_
int vsiz;
char buf[32];
int siz;
- const char *vbuf = tchdbget(db->str, kbuf, ksiz, &vsiz);
+ char *vbuf = tchdbget(db->str, kbuf, ksiz, &vsiz);
if (vbuf == NULL) {
if (tchdbecode(db->str) == TCENOREC) rv = num;
else err = true;
}
else {
if (tcstrisnum(vbuf)) rv = tcatoi(vbuf) + num;
else err = true;
+ free(vbuf);
}
if (!err) {
siz = sprintf(buf, "%lld", (long long) rv);

0 comments on commit 15c59c6

Please sign in to comment.