fix xact.c for bad pointer checking

From: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
To: pgsql-patches(at)postgresql(dot)org
Subject: fix xact.c for bad pointer checking
Date: 2004-08-03 10:35:19
Message-ID: 1091529319.24603.90.camel@jeff
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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")));

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-08-03 14:28:42 Re: psql latex bugfixes
Previous Message Andreas Pflug 2004-08-03 10:03:56 Re: make fails if path has spaces