X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=3c9e70ddad6439ee362d9187c751151eca60d32a;hb=49e614cb2878f0664c9f44f9f24cb1d81116de21;hp=d7811bd7a6fd566e992c505a1d81770aa1790b18;hpb=df5b86c84d896eb2d74a8757c234492c1d1fc3be;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index d7811bd7a..3c9e70dda 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -55,7 +55,7 @@ LTTNG_HIDDEN char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) { - char *cut_path, *try_path = NULL, *try_path_prev = NULL; + char *cut_path = NULL, *try_path = NULL, *try_path_prev = NULL; const char *next, *prev, *end; /* Safety net */ @@ -124,7 +124,8 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) /* Free the allocated memory */ free(cut_path); - }; + cut_path = NULL; + } /* Allocate memory for the resolved path if necessary */ if (resolved_path == NULL) { @@ -161,6 +162,8 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) /* Free the allocated memory */ free(cut_path); free(try_path_prev); + cut_path = NULL; + try_path_prev = NULL; /* * Else, we just copy the path in our resolved_path to * return it as is @@ -174,6 +177,7 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) error: free(resolved_path); + free(cut_path); return NULL; }