Skip to content

Commit

Permalink
check for NULL pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Jan 5, 2025
1 parent b70093b commit 6eb2518
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions jni-c-toxcore/jni-c-toxcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
// ----------- version -----------
#define VERSION_MAJOR 0
#define VERSION_MINOR 99
#define VERSION_PATCH 95
static const char global_version_string[] = "0.99.95";
static const char global_version_asan_string[] = "0.99.95-ASAN";
#define VERSION_PATCH 96
static const char global_version_string[] = "0.99.96";
static const char global_version_asan_string[] = "0.99.96-ASAN";
// ----------- version -----------
// ----------- version -----------

Expand Down Expand Up @@ -3128,6 +3128,21 @@ int add_tcp_relay_single(Tox *tox, const char *ip, uint16_t port, const char *ke
int Java_com_zoffcc_applications_trifa_MainActivity_add_1tcp_1relay_1single__real(JNIEnv *env, jobject thiz, jstring ip,
jstring key_hex, long port)
{
if (ip == NULL)
{
return 1;
}

if (key_hex == NULL)
{
return 1;
}

if (tox_global == NULL)
{
return 1;
}

// dbg(9, "add_tcp_relay_single1");
const char *key_hex_str = NULL;
const char *ip_str = NULL;
Expand Down Expand Up @@ -3202,6 +3217,21 @@ int Java_com_zoffcc_applications_trifa_MainActivity_bootstrap_1single__real(JNIE
jobject key_hex, long port)
{
// dbg(9, "bootstrap_single");
if (ip == NULL)
{
return 1;
}

if (key_hex == NULL)
{
return 1;
}

if (tox_global == NULL)
{
return 1;
}

const char *ip_str = (*env)->GetStringUTFChars(env, ip, NULL);
const char *key_hex_str = (*env)->GetStringUTFChars(env, key_hex, NULL);
int res = bootstrap_single(tox_global, ip_str, (uint16_t)port, key_hex_str);
Expand Down

0 comments on commit 6eb2518

Please sign in to comment.