summaryrefslogtreecommitdiffstats
path: root/src/protocol.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol.c')
-rw-r--r--src/protocol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/protocol.c b/src/protocol.c
index aca5f94..fb6a33c 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -242,6 +242,8 @@ char *sslist()
int ssstore(char *key)
{
+ char *st_str = NULL;
+
check(key != NULL && strlen(key) > 0, "key invalid");
check(tst != NULL, "tstree not initialized");
@@ -253,15 +255,21 @@ int ssstore(char *key)
check(rec->deleted != 1, "record was deleted");
// 2. stringify the stats.
- char *st_str = Stats_stringify(rec->st);
+ st_str = Stats_stringify(rec->st);
check(st_str != NULL, "stats stringify failed");
// 3. store stats in db.
int rc = db_store(key, st_str);
check(rc == 0, "db store failed");
+ // 4. cleanup.
+ free(st_str);
+
return 0;
error:
+ if (st_str) {
+ free(st_str);
+ }
return -1;
}