ancient sequence point bug - Mailing list pgsql-hackers

From Peter Eisentraut
Subject ancient sequence point bug
Date
Msg-id 1366166131.8318.10.camel@vanquo.pezone.net
Whole thread Raw
Responses Re: ancient sequence point bug
List pgsql-hackers
This code in bootstrap.c contains a sequence point violation (or
whatever that is really called):
       while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)       {           (*app)->am_oid =
HeapTupleGetOid(tup);          memmove((char *) &(*app++)->am_typ,                   (char *) GETSTRUCT(tup),
       sizeof((*app)->am_typ));       }
 

In commit 1aebc361, another place in the same file was fixed like this:

@@ -445,13 +455,13 @@ struct typmap       while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))       {
(*app)->am_oid= tup->t_data->t_oid;
 
-           memmove((char *) &(*app++)->am_typ,
-                   (char *) GETSTRUCT(tup),
-                   sizeof((*app)->am_typ));
+           memcpy((char *) &(*app)->am_typ,
+                  (char *) GETSTRUCT(tup),
+                  sizeof((*app)->am_typ));
+           app++;       }       heap_endscan(scan);       heap_close(rel, NoLock);

I think the same (move the app++, and change to memcpy (optionally))
should be done in the first case as well.




pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Enabling Checksums
Next
From: Tom Lane
Date:
Subject: Re: ancient sequence point bug