ckiss

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

commit 4b0dbe865b8e6ac8f78199152f3091e54bfa5a42
parent 6ea8b2ac06382a2f30383ef19a4fcbc3197d8463
Author: aabacchus <ben@bvnf.space>
Date:   Sat, 22 Apr 2023 03:31:59 +0100

misc fixes

Diffstat:
Msrc/list.c | 1+
Msrc/utils.c | 8+++++---
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/list.c b/src/list.c @@ -21,6 +21,7 @@ pkg_print(char *pkg, struct env *e) { printf("%s %s", pkg, buf); + free(buf); free(p); fclose(f); } diff --git a/src/utils.c b/src/utils.c @@ -128,6 +128,8 @@ char ** find_in_path(char *name, char **path, mode_t test_flags, bool limit, bool isglob) { char **s = NULL, **tmp; int n = 0; + if (path == NULL || name == NULL) + return s; for (int i = 0; path[i] != NULL; i++) { char *file = concat(path[i], "/", name, NULL); char **list = NULL; @@ -381,15 +383,15 @@ setup_env(void) { void destroy_env(struct env *e) { - for (int i = 0; e->hooks[i] != NULL; i++) + for (int i = 0; e->hooks && e->hooks[i] != NULL; i++) free(e->hooks[i]); free(e->hooks); - for (int i = 0; e->kiss_path[i] != NULL; i++) + for (int i = 0; e->kiss_path && e->kiss_path[i] != NULL; i++) free(e->kiss_path[i]); free(e->kiss_path); - for (int i = 0; e->path[i] != NULL; i++) + for (int i = 0; e->path && e->path[i] != NULL; i++) free(e->path[i]); free(e->path);