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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy