From 52f839e89936f85006ddb0ed69ebcf85e9c5bed5 Mon Sep 17 00:00:00 2001 From: Eric House Date: Wed, 20 Mar 2019 13:31:35 -0700 Subject: [PATCH] fix null procptr crash in jni I can't reproduce this, but while testing recovery from DatagramSocket recreation in RelayService got enough to know that somehow a timer's procptr's not set. So test before calling, and log instead of crashing. --- xwords4/android/jni/utilwrapper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xwords4/android/jni/utilwrapper.c b/xwords4/android/jni/utilwrapper.c index 03eab0bf4..0e0373dcc 100644 --- a/xwords4/android/jni/utilwrapper.c +++ b/xwords4/android/jni/utilwrapper.c @@ -304,15 +304,19 @@ and_util_engineProgressCallback( XW_UtilCtxt* uc ) bool utilTimerFired( XW_UtilCtxt* uc, XWTimerReason why, int handle ) { - bool handled; + bool handled = false; AndUtil* util = (AndUtil*)uc; TimerStorage* timerStorage = &util->timerStorage[why]; if ( handle == (int)timerStorage ) { - handled = (*timerStorage->proc)( timerStorage->closure, why ); + XWTimerProc proc = timerStorage->proc; + if ( !!proc ) { + handled = (*proc)( timerStorage->closure, why ); + } else { + XP_LOGF( "%s(why=%d): ERROR: no proc set", __func__, why ); + } } else { XP_LOGF( "%s: mismatch: handle=%d; timerStorage=%d", __func__, handle, (int)timerStorage ); - handled = false; } return handled; }