diff --git a/core_option_manager.c b/core_option_manager.c index d0f6896d95..5cb14d350b 100644 --- a/core_option_manager.c +++ b/core_option_manager.c @@ -1262,31 +1262,35 @@ void core_option_manager_free(core_option_manager_t *opt) for (i = 0; i < opt->size; i++) { - if (opt->opts[i].desc) - free(opt->opts[i].desc); - if (opt->opts[i].desc_categorized) - free(opt->opts[i].desc_categorized); - if (opt->opts[i].info) - free(opt->opts[i].info); - if (opt->opts[i].info_categorized) - free(opt->opts[i].info_categorized); - if (opt->opts[i].key) - free(opt->opts[i].key); - if (opt->opts[i].category_key) - free(opt->opts[i].category_key); + struct core_option *option = (struct core_option*)&opt->opts[i]; + if (option) + { + if (option->desc) + free(option->desc); + if (option->desc_categorized) + free(option->desc_categorized); + if (option->info) + free(option->info); + if (option->info_categorized) + free(option->info_categorized); + if (option->key) + free(option->key); + if (option->category_key) + free(option->category_key); - if (opt->opts[i].vals) - string_list_free(opt->opts[i].vals); - if (opt->opts[i].val_labels) - string_list_free(opt->opts[i].val_labels); + if (option->vals) + string_list_free(option->vals); + if (option->val_labels) + string_list_free(option->val_labels); - opt->opts[i].desc = NULL; - opt->opts[i].desc_categorized = NULL; - opt->opts[i].info = NULL; - opt->opts[i].info_categorized = NULL; - opt->opts[i].key = NULL; - opt->opts[i].category_key = NULL; - opt->opts[i].vals = NULL; + option->desc = NULL; + option->desc_categorized = NULL; + option->info = NULL; + option->info_categorized = NULL; + option->key = NULL; + option->category_key = NULL; + option->vals = NULL; + } } if (opt->option_map) @@ -1318,11 +1322,11 @@ void core_option_manager_free(core_option_manager_t *opt) * specified option category if successful, * otherwise NULL. **/ -const char *core_option_manager_get_category_desc(core_option_manager_t *opt, - const char *key) +const char *core_option_manager_get_category_desc( + core_option_manager_t *opt, const char *key) { - uint32_t key_hash; size_t i; + uint32_t key_hash; if ( !opt || string_is_empty(key)) @@ -1360,11 +1364,11 @@ const char *core_option_manager_get_category_desc(core_option_manager_t *opt, const char *core_option_manager_get_category_info(core_option_manager_t *opt, const char *key) { - uint32_t key_hash; size_t i; + uint32_t key_hash; - if (!opt || - string_is_empty(key)) + if ( !opt + || string_is_empty(key)) return NULL; key_hash = core_option_manager_hash_string(key); diff --git a/deps/mbedtls/pkparse.c b/deps/mbedtls/pkparse.c index dae2e1efdf..2bb8c99a65 100644 --- a/deps/mbedtls/pkparse.c +++ b/deps/mbedtls/pkparse.c @@ -306,7 +306,7 @@ static int pk_group_from_specified( const mbedtls_asn1_buf *params, mbedtls_ecp_ p += len; /* Ignore seed BIT STRING OPTIONAL */ - if( ( ret = mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_BIT_STRING ) ) == 0 ) + if( (mbedtls_asn1_get_tag( &p, end_curve, &len, MBEDTLS_ASN1_BIT_STRING)) == 0 ) p += len; if( p != end_curve ) @@ -316,25 +316,23 @@ static int pk_group_from_specified( const mbedtls_asn1_buf *params, mbedtls_ecp_ /* * ECPoint ::= OCTET STRING */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + if ((ret = mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); - if( ( ret = mbedtls_ecp_point_read_binary( grp, &grp->G, - ( const unsigned char *) p, len ) ) != 0 ) + if ((ret = mbedtls_ecp_point_read_binary( grp, &grp->G, + ( const unsigned char *) p, len ) ) != 0 ) { /* * If we can't read the point because it's compressed, cheat by * reading only the X coordinate and the parity bit of Y. */ - if( ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE || - ( p[0] != 0x02 && p[0] != 0x03 ) || - len != mbedtls_mpi_size( &grp->P ) + 1 || - mbedtls_mpi_read_binary( &grp->G.X, p + 1, len - 1 ) != 0 || - mbedtls_mpi_lset( &grp->G.Y, p[0] - 2 ) != 0 || - mbedtls_mpi_lset( &grp->G.Z, 1 ) != 0 ) - { + if (ret != MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE + || ( p[0] != 0x02 && p[0] != 0x03 ) + || len != mbedtls_mpi_size( &grp->P ) + 1 + || mbedtls_mpi_read_binary( &grp->G.X, p + 1, len - 1 ) != 0 + || mbedtls_mpi_lset( &grp->G.Y, p[0] - 2 ) != 0 + || mbedtls_mpi_lset( &grp->G.Z, 1 ) != 0 ) return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT ); - } } p += len; @@ -342,16 +340,15 @@ static int pk_group_from_specified( const mbedtls_asn1_buf *params, mbedtls_ecp_ /* * order INTEGER */ - if( ( ret = mbedtls_asn1_get_mpi( &p, end, &grp->N ) ) != 0 ) - return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret ); + if ((ret = mbedtls_asn1_get_mpi( &p, end, &grp->N)) != 0) + return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT + ret); grp->nbits = mbedtls_mpi_bitlen( &grp->N ); /* * Allow optional elements by purposefully not enforcing p == end here. */ - - return( 0 ); + return 0; } /* @@ -519,12 +516,12 @@ static int pk_get_rsapubkey( unsigned char **p, return( MBEDTLS_ERR_PK_INVALID_PUBKEY + MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); - if( ( ret = mbedtls_rsa_check_pubkey( rsa ) ) != 0 ) - return( MBEDTLS_ERR_PK_INVALID_PUBKEY ); + if( (mbedtls_rsa_check_pubkey(rsa)) != 0 ) + return MBEDTLS_ERR_PK_INVALID_PUBKEY; rsa->len = mbedtls_mpi_size( &rsa->N ); - return( 0 ); + return 0; } #endif /* MBEDTLS_RSA_C */ @@ -1185,22 +1182,18 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, * error */ #if defined(MBEDTLS_PKCS12_C) || defined(MBEDTLS_PKCS5_C) - if( ( ret = pk_parse_key_pkcs8_encrypted_der( pk, key, keylen, - pwd, pwdlen ) ) == 0 ) - { - return( 0 ); - } + if( ( ret = pk_parse_key_pkcs8_encrypted_der(pk, key, keylen, + pwd, pwdlen ) ) == 0 ) + return 0; mbedtls_pk_free( pk ); if( ret == MBEDTLS_ERR_PK_PASSWORD_MISMATCH ) - { - return( ret ); - } + return ret; #endif /* MBEDTLS_PKCS12_C || MBEDTLS_PKCS5_C */ - if( ( ret = pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen ) ) == 0 ) - return( 0 ); + if ((pk_parse_key_pkcs8_unencrypted_der( pk, key, keylen)) == 0) + return 0; mbedtls_pk_free( pk ); @@ -1208,11 +1201,9 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_RSA ) ) == NULL ) return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); - if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || - ( ret = pk_parse_key_pkcs1_der( mbedtls_pk_rsa( *pk ), key, keylen ) ) == 0 ) - { - return( 0 ); - } + if( (mbedtls_pk_setup(pk, pk_info)) != 0 + || (pk_parse_key_pkcs1_der( mbedtls_pk_rsa(*pk), key, keylen)) == 0) + return 0; mbedtls_pk_free( pk ); #endif /* MBEDTLS_RSA_C */ @@ -1221,11 +1212,9 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, if( ( pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ) ) == NULL ) return( MBEDTLS_ERR_PK_UNKNOWN_PK_ALG ); - if( ( ret = mbedtls_pk_setup( pk, pk_info ) ) != 0 || - ( ret = pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), key, keylen ) ) == 0 ) - { - return( 0 ); - } + if( (mbedtls_pk_setup( pk, pk_info)) != 0 + || (pk_parse_key_sec1_der( mbedtls_pk_ec( *pk ), key, keylen)) == 0 ) + return 0; mbedtls_pk_free( pk ); #endif /* MBEDTLS_ECP_C */ diff --git a/deps/mbedtls/rsa.c b/deps/mbedtls/rsa.c index fb19f441ce..0201fec89b 100644 --- a/deps/mbedtls/rsa.c +++ b/deps/mbedtls/rsa.c @@ -1485,21 +1485,21 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, * Bleichenbacher's forgery attack against lax PKCS#1v1.5 verification. */ p0 = p; - if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, + if( ( mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); if( p != p0 + 2 || asn1_len + 2 != len ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); p0 = p; - if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, + if( ( mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); if( p != p0 + 2 || asn1_len + 6 + hashlen != len ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); p0 = p; - if( ( ret = mbedtls_asn1_get_tag( &p, end, &oid.len, MBEDTLS_ASN1_OID ) ) != 0 ) + if( ( mbedtls_asn1_get_tag( &p, end, &oid.len, MBEDTLS_ASN1_OID ) ) != 0 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); if( p != p0 + 2 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); @@ -1517,13 +1517,13 @@ int mbedtls_rsa_rsassa_pkcs1_v15_verify( mbedtls_rsa_context *ctx, * assume the algorithm parameters must be NULL */ p0 = p; - if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_NULL ) ) != 0 ) + if( ( mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_NULL ) ) != 0 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); if( p != p0 + 2 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); p0 = p; - if( ( ret = mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) + if( ( mbedtls_asn1_get_tag( &p, end, &asn1_len, MBEDTLS_ASN1_OCTET_STRING ) ) != 0 ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); if( p != p0 + 2 || asn1_len != hashlen ) return( MBEDTLS_ERR_RSA_VERIFY_FAILED ); diff --git a/deps/mbedtls/x509_crl.c b/deps/mbedtls/x509_crl.c index bf79d9d9db..470c72da8b 100644 --- a/deps/mbedtls/x509_crl.c +++ b/deps/mbedtls/x509_crl.c @@ -300,8 +300,8 @@ int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING } */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, - MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) + if( ( mbedtls_asn1_get_tag(&p, end, &len, + MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE)) != 0 ) { mbedtls_x509_crl_free( crl ); return( MBEDTLS_ERR_X509_INVALID_FORMAT ); @@ -350,9 +350,9 @@ int mbedtls_x509_crl_parse_der( mbedtls_x509_crl *chain, crl->version++; - if( ( ret = mbedtls_x509_get_sig_alg( &crl->sig_oid, &sig_params1, + if( ( mbedtls_x509_get_sig_alg(&crl->sig_oid, &sig_params1, &crl->sig_md, &crl->sig_pk, - &crl->sig_opts ) ) != 0 ) + &crl->sig_opts)) != 0 ) { mbedtls_x509_crl_free( crl ); return( MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG ); diff --git a/deps/mbedtls/x509_crt.c b/deps/mbedtls/x509_crt.c index 529dfdcad1..d38c119c90 100644 --- a/deps/mbedtls/x509_crt.c +++ b/deps/mbedtls/x509_crt.c @@ -682,7 +682,7 @@ static int x509_crt_parse_der_core( mbedtls_x509_crt *crt, const unsigned char * * signatureAlgorithm AlgorithmIdentifier, * signatureValue BIT STRING } */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + if( ( mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) { mbedtls_x509_crt_free( crt ); diff --git a/deps/mbedtls/x509_csr.c b/deps/mbedtls/x509_csr.c index 8483d1fde3..e7401c16e4 100644 --- a/deps/mbedtls/x509_csr.c +++ b/deps/mbedtls/x509_csr.c @@ -120,7 +120,7 @@ int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr, * signature BIT STRING * } */ - if( ( ret = mbedtls_asn1_get_tag( &p, end, &len, + if( ( mbedtls_asn1_get_tag( &p, end, &len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE ) ) != 0 ) { mbedtls_x509_csr_free( csr ); @@ -226,7 +226,7 @@ int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr, return( ret ); } - if( ( ret = mbedtls_x509_get_sig_alg( &csr->sig_oid, &sig_params, + if( (mbedtls_x509_get_sig_alg( &csr->sig_oid, &sig_params, &csr->sig_md, &csr->sig_pk, &csr->sig_opts ) ) != 0 ) { @@ -247,7 +247,7 @@ int mbedtls_x509_csr_parse_der( mbedtls_x509_csr *csr, MBEDTLS_ERR_ASN1_LENGTH_MISMATCH ); } - return( 0 ); + return 0; } /* diff --git a/gfx/common/d3dcompiler_common.c b/gfx/common/d3dcompiler_common.c index ef74e07961..7db73577d3 100644 --- a/gfx/common/d3dcompiler_common.c +++ b/gfx/common/d3dcompiler_common.c @@ -132,14 +132,14 @@ bool d3d_compile(const char* src, size_t len, src, len, src_name, NULL, NULL, entrypoint, target, compileflags, 0, out, &error_msg))) { - if (error_msg) + const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg); + if (msg) { - const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg); RARCH_ERR("D3DCompile failed: %s.\n", msg); /* Place a breakpoint here, if you want, to see shader compilation issues */ - Release(error_msg); } + Release(error_msg); return false; } @@ -160,12 +160,10 @@ bool d3d_compile_from_file(LPCWSTR filename, filename, NULL, NULL, entrypoint, target, compileflags, 0, out, &error_msg))) { - if (error_msg) - { - RARCH_ERR("D3DCompile failed: %s.\n", - (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg)); - Release(error_msg); - } + const char* msg = (const char*)error_msg->lpVtbl->GetBufferPointer(error_msg); + if (msg) + RARCH_ERR("D3DCompile failed: %s.\n", msg); + Release(error_msg); return false; } diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index da56ba6d29..d49d271ae6 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -31,6 +31,7 @@ #include #endif /* !defined(_XBOX) */ #include +#include #include #include diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index cce10401b6..5d434ad6d2 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -142,6 +142,7 @@ rxml_document_t *rxml_load_document_string(const char *str) doc = (rxml_document_t*)malloc(sizeof(*doc)); if (!doc) goto error; + doc->root_node = NULL; yxml_init(&x, buf->xml, BUFSIZE); diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 2be29f33eb..cd07795be9 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -593,7 +593,7 @@ static int general_push(menu_displaylist_info_t *info, CHECK_SIZE(strlen(sysinfo.valid_extensions) + 1); if (_len > 0) newstr2[_len++] = '|'; - _len += strlcpy(newstr2 + _len, sysinfo.valid_extensions, size - _len); + strlcpy(newstr2 + _len, sysinfo.valid_extensions, size - _len); } #endif diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 4d53797da5..eb1d413a85 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -1585,7 +1585,7 @@ static int action_bind_sublabel_subsystem_load( { size_t _len = strlcat(buf, path_basename(content_get_subsystem_rom(j)), sizeof(buf)); if (j != content_get_subsystem_rom_id() - 1) - _len += strlcpy(buf + _len, "\n", sizeof(buf) - _len); + strlcpy(buf + _len, "\n", sizeof(buf) - _len); } if (!string_is_empty(buf)) diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index 1e2d9fc43f..fd1cc5d7d0 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -2997,7 +2997,10 @@ static void ozone_draw_icon( draw.pipeline_id = 0; if (draw.height > 0 && draw.width > 0) - dispctx->draw(&draw, userdata, video_width, video_height); + { + if (dispctx && dispctx->draw) + dispctx->draw(&draw, userdata, video_width, video_height); + } } static int ozone_wiggle(ozone_handle_t* ozone, float t) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c0d3d9d07d..f7ce006116 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2790,14 +2790,14 @@ static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb) sizeof(sysname)); __len = fill_pathname_join_special(texturepath, iconpath, sysname, sizeof(texturepath)); - __len += strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len); + strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len); /* If the playlist icon doesn't exist return default */ if (!path_is_valid(texturepath)) { __len = fill_pathname_join_special(texturepath, iconpath, "default", sizeof(texturepath)); - __len += strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len); + strlcpy(texturepath + __len, ".png", sizeof(texturepath) - __len); } ti.width = 0; diff --git a/retroarch.c b/retroarch.c index da7b653a3b..8d25313eb2 100644 --- a/retroarch.c +++ b/retroarch.c @@ -4813,11 +4813,13 @@ bool command_event(enum event_command cmd, void *data) sizeof(tmp_netplay_server))) { netplay_server = tmp_netplay_server; - netplay_session = strdup(tmp_netplay_session); + if (p_rarch->connect_mitm_id) + netplay_session = strdup(p_rarch->connect_mitm_id); + else + netplay_session = strdup(tmp_netplay_session); } - - if (p_rarch->connect_mitm_id) - netplay_session = strdup(p_rarch->connect_mitm_id); + else if (p_rarch->connect_mitm_id) + netplay_session = strdup(p_rarch->connect_mitm_id); if (p_rarch->connect_host) { diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 84dcd7bf1c..c9d19b3669 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -141,8 +141,8 @@ static unsigned input_autoconfigure_get_config_file_affinity( /* Parse config file */ _len = strlcpy(config_key, "input_vendor_id", sizeof(config_key)); - _len += strlcpy(config_key + _len, config_key_postfix, - sizeof(config_key) - _len); + strlcpy(config_key + _len, config_key_postfix, + sizeof(config_key) - _len); if (config_get_int(config, config_key, &tmp_int)) config_vid = (uint16_t)tmp_int; @@ -178,8 +178,8 @@ static unsigned input_autoconfigure_get_config_file_affinity( /* Check for matching device name */ _len = strlcpy(config_key, "input_device", sizeof(config_key)); - _len += strlcpy(config_key + _len, config_key_postfix, - sizeof(config_key) - _len); + strlcpy(config_key + _len, config_key_postfix, + sizeof(config_key) - _len); if ( (entry = config_get_entry(config, config_key)) && !string_is_empty(entry->value) && string_is_equal(entry->value,