fix xact.c for bad pointer checking - Mailing list pgsql-patches

From Jeff Davis
Subject fix xact.c for bad pointer checking
Date
Msg-id 1091529319.24603.90.camel@jeff
Whole thread Raw
List pgsql-patches
I haven't posted a code patch before, so please be a little patient.

In the 2004-08-02 snapshot, the following sequence causes a crash
(thanks to Christopher Kings-Lynne for finding this bug):

test=# begin;
BEGIN
test=# savepoint "A";
SAVEPOINT
test=# rollback to a;
server closed the connection unexpectedly

--8<--snip--8<--

This seems to have been caused by bad pointer checking in xact.c. I have
attached a patch which fixes that crash. I do not see any side effects,
and it doesn't look like anything needs to additionally be cleaned up,
since that seems to be the same execution path the orginal author
intended for an invalid savepoint name anyway.

Regards,
    Jeff Davis


--- src/backend/access/transam/xact.c.old  2004-08-03 03:18:12.000000000
-0700
+++ src/backend/access/transam/xact.c      2004-08-03 03:19:05.000000000
-0700
@@ -2529,7 +2529,7 @@
                target = target->parent;

                /* we don't cross savepoint level boundaries */
-               if (target->savepointLevel != s->savepointLevel)
+               if (PointerIsValid(target) && (target->savepointLevel !=
s->savepointLevel))
                        ereport(ERROR,

(errcode(ERRCODE_S_E_INVALID_SPECIFICATION),
                                         errmsg("no such savepoint")));



pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: postgres-zh_TW.po for 7.5
Next
From: Tom Lane
Date:
Subject: Re: psql latex bugfixes