Avoid NULL pointer dereference in isolationtester
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 14 Jan 2012 21:58:49 +0000 (18:58 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Sat, 14 Jan 2012 22:01:32 +0000 (19:01 -0300)
src/test/isolation/isolationtester.c

index 1d339e9c577c506c28641a9bbb4dd74ed72fd8dd..b35e533b66c5143448c03e6748505dc6ed0cbac7 100644 (file)
@@ -406,14 +406,16 @@ run_named_permutations(TestSpec * testspec)
        /* Find all the named steps from the lookup table */
        for (j = 0; j < p->nsteps; j++)
        {
-           steps[j] = *((Step **) bsearch(p->stepnames[j], allsteps, nallsteps,
-                                        sizeof(Step *), &step_bsearch_cmp));
-           if (steps[j] == NULL)
+           Step    **this = (Step **) bsearch(p->stepnames[j], allsteps,
+                                              nallsteps, sizeof(Step *),
+                                              &step_bsearch_cmp);
+           if (this == NULL)
            {
                fprintf(stderr, "undefined step \"%s\" specified in permutation\n",
                        p->stepnames[j]);
                exit_nicely();
            }
+           steps[j] = *this;
        }
 
        run_permutation(testspec, p->nsteps, steps);