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 );
|
GamePtr gamePtr = loadMakeGame( context, lock );
|
||||||
if ( null != gamePtr ) {
|
if ( null != gamePtr ) {
|
||||||
|
Assert.assertTrue( XwJNI.game_hasComms( gamePtr )
|
||||||
|
|| !BuildConfig.DEBUG );
|
||||||
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
|
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
|
||||||
for ( CommsAddrRec addr : addrs ) {
|
for ( CommsAddrRec addr : addrs ) {
|
||||||
CommsConnTypeSet conTypes = addr.conTypes;
|
CommsConnTypeSet conTypes = addr.conTypes;
|
||||||
|
|
|
@ -1631,6 +1631,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getAddrs
|
||||||
jobjectArray result = NULL;
|
jobjectArray result = NULL;
|
||||||
XWJNI_START();
|
XWJNI_START();
|
||||||
XP_ASSERT( state->game.comms );
|
XP_ASSERT( state->game.comms );
|
||||||
|
if ( !!state->game.comms ) {
|
||||||
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
CommsAddrRec addrs[MAX_NUM_PLAYERS];
|
||||||
XP_U16 count = VSIZE(addrs);
|
XP_U16 count = VSIZE(addrs);
|
||||||
comms_getAddrs( state->game.comms, addrs, &count );
|
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, jaddr );
|
||||||
}
|
}
|
||||||
deleteLocalRef( env, clas );
|
deleteLocalRef( env, clas );
|
||||||
|
}
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue