[PATCH][BUG FIX] Pointer arithmetic with NULL - Mailing list pgsql-hackers

From Ranier Vilela
Subject [PATCH][BUG FIX] Pointer arithmetic with NULL
Date
Msg-id MN2PR18MB29278065C7E7B4F20333BDFEE3490@MN2PR18MB2927.namprd18.prod.outlook.com
Whole thread Raw
Responses Re: [PATCH][BUG FIX] Pointer arithmetic with NULL  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
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;
     }

     /*

Attachment

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: range_agg
Next
From: Ranier Vilela
Date:
Subject: [PATCH][BUG FIX] Pointer var initilialized with boolean.