mirror of
https://github.com/postgres/postgres.git
synced 2026-06-11 01:30:11 -04:00
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
This commit is contained in:
parent
6c46e8a5df
commit
31d8d4740f
1 changed files with 1 additions and 1 deletions
|
|
@ -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++)
|
||||
|
|
|
|||
Loading…
Reference in a new issue