diff options
author | Romain Naour <romain.naour@gmail.com> | 2016-03-22 22:19:54 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2016-03-23 10:52:41 +0100 |
commit | 90a9b9910cb7800f1bd4981b19f34d220393ff2c (patch) | |
tree | 1baa7ba791eaeb748e72ca3c377f1a111106bfba | |
parent | 7ce27dc517093a7b52408e2d6a9b6d1a063eb3b1 (diff) | |
download | util-linux-90a9b9910cb7800f1bd4981b19f34d220393ff2c.tar.gz |
lsipc: don't free shm data if no shm id is found
There is a segfault in do_shm_global() when ipc_shm_get_info() return 0 and
ipc_shm_free_info() is called.
When no shm id is found, the memory allocated in shmds by ipc_shm_get_info() is
already free when ipc_shm_free_info() is called.
Move ipc_shm_free_info(shmds) inside the if statement where at least one shm id
is found.
Signed-off-by: Romain Naour <romain.naour@gmail.com>
-rw-r--r-- | sys-utils/lsipc.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/sys-utils/lsipc.c b/sys-utils/lsipc.c index 938728ada..195ee15de 100644 --- a/sys-utils/lsipc.c +++ b/sys-utils/lsipc.c @@ -1071,14 +1071,13 @@ static void do_shm_global(struct libscols_table *tb) ++nsegs; sum_segsz += shmdsp->shm_segsz; } + ipc_shm_free_info(shmds); } global_set_data(tb, "SHMMNI", _("Shared memory segments"), nsegs, lim.shmmni, 1); global_set_data(tb, "SHMALL", _("Shared memory pages"), sum_segsz / getpagesize(), lim.shmall, 1); global_set_data(tb, "SHMMAX", _("Max size of shared memory segment (bytes)"), 0, lim.shmmax, 0); global_set_data(tb, "SHMMIN", _("Min size of shared memory segment (bytes)"), 0, lim.shmmin, 0); - - ipc_shm_free_info(shmds); } int main(int argc, char *argv[]) |