Fix occasional segfault when query cache is enabled.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 20 Dec 2016 02:38:12 +0000 (11:38 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 20 Dec 2016 02:40:12 +0000 (11:40 +0900)
Per bug 263.

src/query_cache/pool_memqcache.c
src/utils/mmgr/mcxt.c

index 06ce6b9da1030b0ce4e7b0c9bd77e0620ad4e767..b78169325ca068248931fc829966e25eb2292e8f 100644 (file)
@@ -3089,6 +3089,8 @@ static void pool_check_and_discard_cache_buffer(int num_oids, int *oids)
                        continue;
 
                soids = (int *)pool_get_buffer(cache->oids, &len);
+               if (!soids || !len)
+                       continue;
 
                for(j=0;j<cache->num_oids;j++)
                {
index a1a490f367326d0703635f50b6ca3653c8330200..0eae52012b2577ce5e26a40e9dc14cc91a9b6125 100644 (file)
@@ -703,6 +703,9 @@ pfree(void *pointer)
        Assert(pointer != NULL);
        Assert(pointer == (void *) MAXALIGN(pointer));
 
+       if (pointer == NULL)
+               return;
+
        /*
         * OK, it's probably safe to look at the chunk header.
         */