nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit a3d98fc2ed142ec92af337578acbc4940b08ea07
parent f7217c512e54c0991af35627ecaaba3d8b7fb9be
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 14 Nov 2019 19:45:03 -0500

nserver: protocol: Update sslist.

* nserver/src/protocol.c (sslist): Destroy `ks` after use.

Diffstat:
nserver/src/protocol.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c @@ -125,10 +125,12 @@ char *ssdump(char *key) char *sslist() { + DArray *ks = NULL; + check(hash != NULL, "hash not initiliazed"); // 1. Get keys. - DArray *ks = Hashmap_keys(hash); + ks = Hashmap_keys(hash); check(ks != NULL, "error getting keys"); bstring ks_str = bfromcstr(""); @@ -147,8 +149,17 @@ char *sslist() check(rc == BSTR_OK, "bstr newline concat failed"); } + // cleanup. + DArray_destroy(ks); + return bstr2cstr(ks_str, ' '); error: + + // cleanup + if (ks) { + DArray_destroy(ks); + } + return NULL; }