diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-08-17 17:02:48 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-08-17 17:02:48 -0700 |
commit | e6ec620d8b2d576908889476eb7da716d2e4bda2 (patch) | |
tree | 6bb85e271166a12e4f3f7e0dee02301d25a4e69c | |
parent | Merge branch 'es/test-cmp-typocatcher' (diff) | |
parent | progress: don't dereference before checking for NULL (diff) | |
download | tgif-e6ec620d8b2d576908889476eb7da716d2e4bda2.tar.xz |
Merge branch 'ma/stop-progress-null-fix'
NULL dereference fix.
* ma/stop-progress-null-fix:
progress: don't dereference before checking for NULL
-rw-r--r-- | progress.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/progress.c b/progress.c index 3eda914518..31014e6fca 100644 --- a/progress.c +++ b/progress.c @@ -319,9 +319,12 @@ static void finish_if_sparse(struct progress *progress) void stop_progress(struct progress **p_progress) { + if (!p_progress) + BUG("don't provide NULL to stop_progress"); + finish_if_sparse(*p_progress); - if (p_progress && *p_progress) { + if (*p_progress) { trace2_data_intmax("progress", the_repository, "total_objects", (*p_progress)->total); @@ -338,7 +341,12 @@ void stop_progress(struct progress **p_progress) void stop_progress_msg(struct progress **p_progress, const char *msg) { - struct progress *progress = *p_progress; + struct progress *progress; + + if (!p_progress) + BUG("don't provide NULL to stop_progress_msg"); + + progress = *p_progress; if (!progress) return; *p_progress = NULL; |