[gnome-builder] counters: check n_counters before iterating it
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] counters: check n_counters before iterating it
- Date: Sat, 3 Oct 2015 22:45:35 +0000 (UTC)
commit 06a732b8198ee3bac3d1c07c340145d8642746a2
Author: Christian Hergert <christian hergert me>
Date: Sat Oct 3 15:45:21 2015 -0700
counters: check n_counters before iterating it
contrib/egg/egg-counter.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/contrib/egg/egg-counter.c b/contrib/egg/egg-counter.c
index 146a353..2c3da29 100644
--- a/contrib/egg/egg-counter.c
+++ b/contrib/egg/egg-counter.c
@@ -256,6 +256,7 @@ _egg_counter_arena_init_remote (EggCounterArena *arena,
gchar name [32];
void *mem = NULL;
guint ncpu;
+ guint n_counters;
int i;
int fd = -1;
@@ -279,6 +280,12 @@ _egg_counter_arena_init_remote (EggCounterArena *arena,
(header.ncpu > g_get_num_processors ()))
goto failure;
+ n_counters = header.n_counters;
+
+ if (header.size <
+ CELLS_PER_HEADER + (((n_counters / COUNTERS_PER_GROUP) + 1) * CELLS_PER_GROUP(header.ncpu)))
+ goto failure;
+
mem = mmap (NULL, header.size, PROT_READ, MAP_SHARED, fd, 0);
if (mem == MAP_FAILED)
@@ -295,7 +302,7 @@ _egg_counter_arena_init_remote (EggCounterArena *arena,
if (header.first_offset != CELLS_PER_HEADER)
goto failure;
- for (i = 0; i < header.n_counters; i++)
+ for (i = 0; i < n_counters; i++)
{
CounterInfo *info;
EggCounter *counter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]