@@ -3094,18 +3094,18 @@ bool
30943094parseTimeLineHistory (const char * filename , const char * content ,
30953095 IdentifySystem * system )
30963096{
3097- char * historyLines [ BUFSIZE ] = { 0 } ;
3098- int lineCount = splitLines (( char * ) content , historyLines , BUFSIZE );
3097+ int lineCount = countLines (( char * ) content ) ;
3098+ char * * historyLines = ( char * * ) calloc ( lineCount , sizeof ( char * ) );
30993099 int lineNumber = 0 ;
31003100
3101- if (lineCount >= PG_AUTOCTL_MAX_TIMELINES )
3101+ if (historyLines == NULL )
31023102 {
3103- log_error ("history file \"%s\" contains %d lines, "
3104- "pg_autoctl only supports up to %d lines" ,
3105- filename , lineCount , PG_AUTOCTL_MAX_TIMELINES - 1 );
3103+ log_error (ALLOCATION_FAILED_ERROR );
31063104 return false;
31073105 }
31083106
3107+ splitLines ((char * ) content , historyLines , lineCount );
3108+
31093109 uint64_t prevend = InvalidXLogRecPtr ;
31103110
31113111 system -> timelines .count = 0 ;
@@ -3141,6 +3141,7 @@ parseTimeLineHistory(const char *filename, const char *content,
31413141 {
31423142 log_error ("Failed to parse history file line %d: \"%s\"" ,
31433143 lineNumber , ptr );
3144+ free (historyLines );
31443145 return false;
31453146 }
31463147
@@ -3149,6 +3150,7 @@ parseTimeLineHistory(const char *filename, const char *content,
31493150 if (!stringToUInt (historyLines [lineNumber ], & (entry -> tli )))
31503151 {
31513152 log_error ("Failed to parse history timeline \"%s\"" , tabptr );
3153+ free (historyLines );
31523154 return false;
31533155 }
31543156
@@ -3167,6 +3169,7 @@ parseTimeLineHistory(const char *filename, const char *content,
31673169 {
31683170 log_error ("Failed to parse history timeline %d LSN \"%s\"" ,
31693171 entry -> tli , lsn );
3172+ free (historyLines );
31703173 return false;
31713174 }
31723175
@@ -3184,6 +3187,8 @@ parseTimeLineHistory(const char *filename, const char *content,
31843187 entry = & (system -> timelines .history [++ system -> timelines .count ]);
31853188 }
31863189
3190+ free (historyLines );
3191+
31873192 /*
31883193 * Create one more entry for the "tip" of the timeline, which has no entry
31893194 * in the history file.
0 commit comments