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 */
/* Free the allocated memory */
free(cut_path);
+ cut_path = NULL;
};
/* Allocate memory for the resolved path if necessary */
error:
free(resolved_path);
+ free(cut_path);
+ free(try_path);
+ free(try_path_prev);
return NULL;
}
ret = unlink(path);
} else {
ret = run_as_unlink(path, uid, gid);
- if (ret < 0) {
- errno = -ret;
- ret = -1;
- }
}
if (ret < 0) {
goto error;