mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-04 20:46:28 +01:00
double-check to avoid crash (by observation)
Chasing a rare play-store-reported JNI crash: test for a null ptr in C and assert/test in Java.
This commit is contained in:
parent
d584c30a43
commit
b6665a15c4
2 changed files with 16 additions and 13 deletions
|
@ -1141,6 +1141,8 @@ public class GameUtils {
|
|||
|
||||
GamePtr gamePtr = loadMakeGame( context, lock );
|
||||
if ( null != gamePtr ) {
|
||||
Assert.assertTrue( XwJNI.game_hasComms( gamePtr )
|
||||
|| !BuildConfig.DEBUG );
|
||||
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
|
||||
for ( CommsAddrRec addr : addrs ) {
|
||||
CommsConnTypeSet conTypes = addr.conTypes;
|
||||
|
|
|
@ -1631,6 +1631,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
|||
jobjectArray result = NULL;
|
||||
XWJNI_START();
|
||||
XP_ASSERT( state->game.comms );
|
||||
if ( !!state->game.comms ) {
|
||||
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||
XP_U16 count = VSIZE(addrs);
|
||||
comms_getAddrs( state->game.comms, addrs, &count );
|
||||
|
@ -1646,7 +1647,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
|||
deleteLocalRef( env, jaddr );
|
||||
}
|
||||
deleteLocalRef( env, clas );
|
||||
|
||||
}
|
||||
XWJNI_END();
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue