summaryrefslogtreecommitdiff
path: root/src/lib/keytab.c
diff options
context:
space:
mode:
authorbpc2003 <wpesfriendnva@gmail.com>2025-03-17 14:40:20 -0400
committerbpc2003 <wpesfriendnva@gmail.com>2025-03-17 14:40:20 -0400
commitf8ad5a7a313070111e9a47195f738740146f71ed (patch)
tree7ac3893b320b92f99c6b79e232d3c5906f750200 /src/lib/keytab.c
parent35d240ce38efb2778723650631485242b4a697d6 (diff)
Fixed a few memory leaks
Diffstat (limited to 'src/lib/keytab.c')
-rw-r--r--src/lib/keytab.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/keytab.c b/src/lib/keytab.c
index f8570a0..c2842c9 100644
--- a/src/lib/keytab.c
+++ b/src/lib/keytab.c
@@ -52,8 +52,10 @@ int setkey(tablist_t **list, int id, char *pair)
(*list)[0].len = id + 1;
}
char **kv = getkv(pair);
- if (kv == NULL)
+ if (kv == NULL) {
+ free(pair);
return 1;
+ }
int idx = hash(kv[0]);
while ((*list)[id].tab[idx].key != NULL &&
@@ -120,8 +122,10 @@ static char **getkv(char *pair)
int i = 0;
while (pair[i] != ':' && i < strlen(pair))
i++;
- if (i >= strlen(pair))
+ if (i >= strlen(pair)) {
+ free(kv);
return NULL;
+ }
kv[0] = calloc(i + 1, sizeof(char));
strncpy(kv[0], pair, i);
kv[1] = calloc(strlen(pair) - i, sizeof(char));