From: | Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> |
---|---|
To: | Ranier Vilela <ranier_gyn(at)hotmail(dot)com> |
Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PATCH][BUG FIX] Pointer arithmetic with NULL |
Date: | 2019-11-22 20:07:41 |
Message-ID: | 20191122200741.rtt2chpc7ni7thhj@development |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Nov 22, 2019 at 05:19:11PM +0000, Ranier Vilela wrote:
>Hi,
>Pointer addition with NULL, is technically undefined behavior.
>
>Best regards.
>Ranier Vilela
>
>--- \dll\postgresql-12.0\a\backend\access\transam\xlog.c Mon Sep 30 17:06:55 2019
>+++ xlog.c Fri Nov 22 13:57:17 2019
>@@ -1861,7 +1861,7 @@
> {
> Assert(((XLogPageHeader) cachedPos)->xlp_magic == XLOG_PAGE_MAGIC);
> Assert(((XLogPageHeader) cachedPos)->xlp_pageaddr == ptr - (ptr % XLOG_BLCKSZ));
>- return cachedPos + ptr % XLOG_BLCKSZ;
>+ return ptr % XLOG_BLCKSZ;
> }
>
> /*
But the value is not necessarily NULL, because it's defined like this:
static char *cachedPos = NULL;
that is, it's a static value - i.e. retained across multiple calls. The
question is whether we can get into that branch before it's set, but
it's certainly not correct to just remove it ...
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-11-22 20:11:09 | Re: Why overhead of SPI is so large? |
Previous Message | Tomas Vondra | 2019-11-22 19:44:40 | Re: WAL archive is lost |