fix: pass clang-tidy

This commit is contained in:
2026-01-16 01:03:32 +01:00
parent 5749263605
commit 9cfe00c197
2 changed files with 8 additions and 1 deletions

View File

@@ -18,7 +18,9 @@
// returns NULL on any error // returns NULL on any error
// otherwise it returns the absolute path of the program that MUST BE FREED // otherwise it returns the absolute path of the program that MUST BE FREED
static char* NULLABLE search_path(const char* NNULLABLE for_binary) { static char* NULLABLE search_path(const char* NNULLABLE for_binary) {
char* path = strdup(getenv("PATH")); char* path_env = getenv("PATH");
if (!path_env) return NULL;
char* path = strdup(path_env);
if (!path) return NULL; if (!path) return NULL;
char* tok = strtok(path, ":"); char* tok = strtok(path, ":");
@@ -42,6 +44,7 @@ static char* NULLABLE search_path(const char* NNULLABLE for_binary) {
tok = strtok(NULL, ":"); tok = strtok(NULL, ":");
} }
free(path);
return NULL; return NULL;
} }

View File

@@ -22,6 +22,10 @@ int read_launch_state(struct LaunchState* NNULLABLE state) {
size_t num = 0; size_t num = 0;
if (getline(&state->username, &num, state_fd) < 0) goto fail; if (getline(&state->username, &num, state_fd) < 0) goto fail;
// not sure I can actually prove it but ughh, getline < 0 will ensure there's
// something in the string and then I think strcspn is bounded to the final
// null byte, so it shouldn't go over
// NOLINTNEXTLINE(clang-analyzer-security.ArrayBound)
state->username[strcspn(state->username, "\n")] = 0; state->username[strcspn(state->username, "\n")] = 0;
num = 0; num = 0;