Fix inappropriate shared memory allocation size for clock hand.
authorTatsuo Ishii <ishii@postgresql.org>
Sat, 26 Oct 2013 02:01:22 +0000 (11:01 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sat, 26 Oct 2013 02:11:02 +0000 (11:11 +0900)
The memory for clock hand was allocated as
sizeof(pool_fsmm_clock_hand)) which is 8 bytes long because the
variable is declared as:

static int *pool_fsmm_clock_hand;

This is plain wrong. The memory size actually needed is only 4 bytes,
which is sizeof(*pool_fsmm_clock_hand)). In other word, the bug
allocated unnecessary 4 bytes, which did nothing bd for the execution
of program. But a bug is a bug.

Per covery report "1111476 Wrong sizeof argument"

src/query_cache/pool_memqcache.c

index a0eabcf8d7bc3beeb2a26f3df201672e9cbc2b79..c8a3075f2e53571a0f36349cf8747b91e71d529a 100644 (file)
@@ -1799,7 +1799,7 @@ static int *pool_fsmm_clock_hand;
  */
 void pool_allocate_fsmm_clock_hand(void)
 {
-       pool_fsmm_clock_hand = pool_shared_memory_create(sizeof(pool_fsmm_clock_hand));
+       pool_fsmm_clock_hand = pool_shared_memory_create(sizeof(*pool_fsmm_clock_hand));
        *pool_fsmm_clock_hand = 0;
 }