Skip to content

Commit bb47eee

Browse files
committed
Merge branch 'em/missing-pager'
When a non-existent program is given as the pager, we tried to reuse an uninitialized child_process structure and crashed, which has been fixed. * em/missing-pager: pager: fix crash when pager program doesn't exist
2 parents 670703e + f917f57 commit bb47eee

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pager.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define DEFAULT_PAGER "less"
99
#endif
1010

11-
static struct child_process pager_process = CHILD_PROCESS_INIT;
11+
static struct child_process pager_process;
1212
static const char *pager_program;
1313

1414
/* Is the value coming back from term_columns() just a guess? */
@@ -124,6 +124,8 @@ void setup_pager(void)
124124

125125
setenv("GIT_PAGER_IN_USE", "true", 1);
126126

127+
child_process_init(&pager_process);
128+
127129
/* spawn the pager */
128130
prepare_pager_args(&pager_process, pager);
129131
pager_process.in = -1;

t/t7006-pager.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,4 +760,9 @@ test_expect_success TTY 'git returns SIGPIPE on propagated signals from pager' '
760760
test_path_is_file pager-used
761761
'
762762

763+
test_expect_success TTY 'non-existent pager doesnt cause crash' '
764+
test_config pager.show invalid-pager &&
765+
test_terminal git show
766+
'
767+
763768
test_done

0 commit comments

Comments
 (0)