summaryrefslogtreecommitdiff
path: root/src/test/isolation/isolationtester.c
diff options
context:
space:
mode:
authorTom Lane2016-08-30 22:22:43 +0000
committerTom Lane2016-08-30 22:22:43 +0000
commit052cc223d5ce1b727f62afff75797c88d82f880b (patch)
treebc60ab35a639f80fd33d8f3391558084d680dbae /src/test/isolation/isolationtester.c
parent9daec77e165de461fca9d5bc3ece86a91aba5804 (diff)
Fix a bunch of places that called malloc and friends with no NULL check.
Where possible, use palloc or pg_malloc instead; otherwise, insert explicit NULL checks. Generally speaking, these are places where an actual OOM is quite unlikely, either because they're in client programs that don't allocate all that much, or they're very early in process startup so that we'd likely have had a fork() failure instead. Hence, no back-patch, even though this is nominally a bug fix. Michael Paquier, with some adjustments by me Discussion: <CAB7nPqRu07Ot6iht9i9KRfYLpDaF2ZuUv5y_+72uP23ZAGysRg@mail.gmail.com>
Diffstat (limited to 'src/test/isolation/isolationtester.c')
-rw-r--r--src/test/isolation/isolationtester.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/test/isolation/isolationtester.c b/src/test/isolation/isolationtester.c
index 908a7ce8002..db2b55982b6 100644
--- a/src/test/isolation/isolationtester.c
+++ b/src/test/isolation/isolationtester.c
@@ -119,7 +119,7 @@ main(int argc, char **argv)
for (i = 0; i < testspec->nsessions; i++)
nallsteps += testspec->sessions[i]->nsteps;
- allsteps = malloc(nallsteps * sizeof(Step *));
+ allsteps = pg_malloc(nallsteps * sizeof(Step *));
n = 0;
for (i = 0; i < testspec->nsessions; i++)
@@ -190,7 +190,7 @@ main(int argc, char **argv)
if (PQresultStatus(res) == PGRES_TUPLES_OK)
{
if (PQntuples(res) == 1 && PQnfields(res) == 1)
- backend_pids[i] = strdup(PQgetvalue(res, 0, 0));
+ backend_pids[i] = pg_strdup(PQgetvalue(res, 0, 0));
else
{
fprintf(stderr, "backend pid query returned %d rows and %d columns, expected 1 row and 1 column",
@@ -286,7 +286,7 @@ run_all_permutations(TestSpec *testspec)
for (i = 0; i < testspec->nsessions; i++)
nsteps += testspec->sessions[i]->nsteps;
- steps = malloc(sizeof(Step *) * nsteps);
+ steps = pg_malloc(sizeof(Step *) * nsteps);
/*
* To generate the permutations, we conceptually put the steps of each
@@ -297,7 +297,7 @@ run_all_permutations(TestSpec *testspec)
* A pile is actually just an integer which tells how many steps we've
* already picked from this pile.
*/
- piles = malloc(sizeof(int) * testspec->nsessions);
+ piles = pg_malloc(sizeof(int) * testspec->nsessions);
for (i = 0; i < testspec->nsessions; i++)
piles[i] = 0;
@@ -345,7 +345,7 @@ run_named_permutations(TestSpec *testspec)
Permutation *p = testspec->permutations[i];
Step **steps;
- steps = malloc(p->nsteps * sizeof(Step *));
+ steps = pg_malloc(p->nsteps * sizeof(Step *));
/* Find all the named steps using the lookup table */
for (j = 0; j < p->nsteps; j++)
@@ -476,8 +476,8 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
return;
}
- waiting = malloc(sizeof(Step *) * testspec->nsessions);
- errorstep = malloc(sizeof(Step *) * testspec->nsessions);
+ waiting = pg_malloc(sizeof(Step *) * testspec->nsessions);
+ errorstep = pg_malloc(sizeof(Step *) * testspec->nsessions);
printf("\nstarting permutation:");
for (i = 0; i < nsteps; i++)