shm: Fix use of uninitialized value: segment's shared-memory type
authorAhmed S. Darwish <darwish.07@gmail.com>
Fri, 17 Jun 2016 19:54:54 +0000 (21:54 +0200)
committerArun Raghavan <arun@arunraghavan.net>
Tue, 21 Jun 2016 10:58:40 +0000 (16:28 +0530)
commit3922bbe7eb94232cc097bc3b7a91f06b2db93df2
treec38baa74852c2b600695cc0e8944aa2ecd05eaa2
parentf58e8c405c573a5a68be410d1add6dd1abeef9d6
shm: Fix use of uninitialized value: segment's shared-memory type

As shown by valgrind

  ==10615== Conditional jump or move depends on uninitialised value(s)
  ==10615==    at 0x5CC0483: shm_marker_size (shm.c:97)
  ==10615==    by 0x5CC1685: shm_attach (shm.c:381)
  ==10615==    by 0x5CC1990: pa_shm_cleanup (shm.c:453)
  ==10615==    by 0x5CC068E: sharedmem_create (shm.c:150)
  ...

Solution is to fix the shm_marker_size() signature itself: At
certain code paths like shm_attach(), we don't want to initialize
_any_ field in the passed SHM segment descriptor except after
making sure all error exit conditions have been passed.

Reported-by: Alexander E. Patrakov <patrakov@gmail.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
src/pulsecore/shm.c