git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6c46e8a)
Guard against reallocation failure in pg_regress
2022年2月24日 19:58:18 +0000 (20:58 +0100)
2022年2月24日 19:58:18 +0000 (20:58 +0100)
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


diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index e6f71c7582ed8739c289ee4b6c48c06074f08940..db8427dd9b572544097182daed32aa2f5e249edb 100644 (file)
--- 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++)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /