diff options
author | Daniel Gustafsson <dgustafsson@postgresql.org> | 2022-02-24 20:58:18 +0100 |
---|---|---|
committer | Daniel Gustafsson <dgustafsson@postgresql.org> | 2022-02-24 20:58:18 +0100 |
commit | 31d8d4740ffb21c9898a21b5018c31e92af6935d (patch) | |
tree | bc662d7a0cd97701aa408ab1d83442d76586288d /src | |
parent | 6c46e8a5dfc9f49e673d76fc6ae097b81d7740ef (diff) | |
download | postgresql-31d8d4740ffb21c9898a21b5018c31e92af6935d.tar.gz postgresql-31d8d4740ffb21c9898a21b5018c31e92af6935d.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/test/regress/pg_regress.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index e6f71c7582e..db8427dd9b5 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -774,7 +774,7 @@ fmtHba(const char *raw) const char *rp; char *wp; - wp = ret = realloc(ret, 3 + strlen(raw) * 2); + wp = ret = pg_realloc(ret, 3 + strlen(raw) * 2); *wp++ = '"'; for (rp = raw; *rp; rp++) |