diff --git a/src/postgres/src/bin/initdb/initdb.c b/src/postgres/src/bin/initdb/initdb.c index d570d7314b26..99906fa1295c 100644 --- a/src/postgres/src/bin/initdb/initdb.c +++ b/src/postgres/src/bin/initdb/initdb.c @@ -1427,11 +1427,13 @@ bootstrap_template1(void) char **bki_lines; char headerline[MAXPGPATH]; char buf[64]; + char **yb_orig_bki_lines; printf(_("running bootstrap script ... ")); fflush(stdout); bki_lines = readfile(bki_file); + yb_orig_bki_lines = bki_lines; /* Check that bki file appears to be of the right version */ @@ -1510,6 +1512,13 @@ bootstrap_template1(void) free(bki_lines); + /* + * YB note: free the memory allocated by readfile(), if not done already. + * Without this, initdb fails on ASAN intermittently. + */ + if (yb_orig_bki_lines != bki_lines) + free(yb_orig_bki_lines); + check_ok(); }