From f0fe4663d5b11f483432932e18d957b2ff54f373 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Sat, 17 Jan 2015 18:26:36 +0000 Subject: [PATCH] Oops, helps to actually commit the fix too.. --- mode_s.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mode_s.c b/mode_s.c index ea5a086..ee569fc 100644 --- a/mode_s.c +++ b/mode_s.c @@ -1493,6 +1493,11 @@ void applyPhaseCorrection(uint16_t *pPayload) { uint32_t early = (pPayload[-1] + pPayload[6]) << 1; uint32_t late = (pPayload[3] + pPayload[10]) << 1; + if (onTime == 0 && early == 0 && late == 0) { + // Blah, can't do anything with this, avoid a divide-by-zero + return; + } + if (early > late) { // Our sample period starts late and so includes some of the next bit.