From 8598c1d9278129637c02ba461fda430ce16c544b Mon Sep 17 00:00:00 2001 From: "NathanNeurotic (Ripto)" <109461996+NathanNeurotic@users.noreply.github.com> Date: Mon, 29 Dec 2025 05:09:14 -0800 Subject: [PATCH] Ensure getMountInfo frees split tokens on all paths --- src/util.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/util.c b/src/util.c index 2d27a56..3072f48 100644 --- a/src/util.c +++ b/src/util.c @@ -154,8 +154,10 @@ int getMountInfo(char *path, char *mountString, size_t mountStringSize, char *mo char **tokens = str_split(path, ':'); int ret = -EINVAL; - if (!tokens) - return -ENOMEM; + if (!tokens) { + ret = -ENOMEM; + goto cleanup; + } for (i = 0; *(tokens + i); i++) ; @@ -214,10 +216,12 @@ int getMountInfo(char *path, char *mountString, size_t mountStringSize, char *mo ret = 0; cleanup: - for (int idx = 0; *(tokens + idx); idx++) { - free(*(tokens + idx)); + if (tokens) { + for (int idx = 0; *(tokens + idx); idx++) { + free(*(tokens + idx)); + } + free(tokens); } - free(tokens); return ret; }