Guard against reallocation failure in pg_regress

Daniel Gustafsson <dgustafsson@postgresql.org>

Commit: 31d8d4740ffb21c9898a21b5018c31e92af6935d
Author: Daniel Gustafsson <dgustafsson@postgresql.org>
Date: 2022-02-24T19:58:18Z
Releases: 15.0
Guard against reallocation failure in pg_regress

realloc() will return NULL on a failed reallocation, so the destination
pointer must be inspected to avoid null pointer dereference.  Further,
assigning the return value to the source pointer leak the allocation in
the case of reallocation failure.  Fix by using pg_realloc instead which
has full error handling.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/9FC7E603-9246-4C62-B466-A39CFAF454AE@yesql.se

Files

PathChange+/−
src/test/regress/pg_regress.c modified +1 −1

Discussion