summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-04-19 01:12:07 -0400
committerrsiddharth <s@ricketyspace.net>2020-04-19 01:12:07 -0400
commit436a0beb7f1191f4237732ad60383e5253674c02 (patch)
treee6de89dd713e9304a415484421d25b4621c0f645
parentd5f23304ee49697df888e54ce7e54ef0823c098c (diff)
protocol.c: Update ssstore.
* src/protocol.c (ssstore): Clean up st_str.
-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;
}