From 83322d8e35a29afc72c2005d5fc0addc65cd94c4 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 12 Jan 2016 14:16:17 -0800 Subject: [PATCH] Guard against unlikely overflow --- geojson.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geojson.c b/geojson.c index 2e8e4b6..b8cb9ec 100644 --- a/geojson.c +++ b/geojson.c @@ -69,6 +69,11 @@ void init_cpus() { CPUS = 1; } + // Guard against short struct index.segment + if (CPUS > 32767) { + CPUS = 32767; + } + // Round down to a power of 2 CPUS = 1 << (int) (log(CPUS) / log(2));