If worktrees is NULL, free_worktrees() should return immediately to prevent a null pointer dereference. Signed-off-by: Caleb White <cdwhite3@xxxxx> --- worktree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/worktree.c b/worktree.c index b08ecce..1cf15b0 100644 --- a/worktree.c +++ b/worktree.c @@ -28,8 +28,9 @@ void free_worktree(struct worktree *worktree) void free_worktrees(struct worktree **worktrees) { - int i = 0; - for (i = 0; worktrees[i]; i++) + if (!worktrees) + return; + for (int i = 0; worktrees[i]; i++) free_worktree(worktrees[i]); free (worktrees); } -- 2.46.2
Attachment:
signature.asc
Description: OpenPGP digital signature