From 436a0beb7f1191f4237732ad60383e5253674c02 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sun, 19 Apr 2020 01:12:07 -0400 Subject: protocol.c: Update ssstore. * src/protocol.c (ssstore): Clean up st_str. --- src/protocol.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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; } -- cgit v1.2.3