Content-Length: 258099 | pFad | http://github.com/postgrespro/postgres/commit/31d8d4740ffb21c9898a21b5018c31e92af6935d

A9 Guard against reallocation failure in pg_regress · postgrespro/postgres@31d8d47 · GitHub
Skip to content

Commit 31d8d47

Browse files
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
1 parent 6c46e8a commit 31d8d47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/test/regress/pg_regress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ fmtHba(const char *raw)
774774
const char *rp;
775775
char *wp;
776776

777-
wp = ret = realloc(ret, 3 + strlen(raw) * 2);
777+
wp = ret = pg_realloc(ret, 3 + strlen(raw) * 2);
778778

779779
*wp++ = '"';
780780
for (rp = raw; *rp; rp++)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/31d8d4740ffb21c9898a21b5018c31e92af6935d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy