diff --git a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp index 02918d2a..998fac80 100644 --- a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp +++ b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp @@ -2220,8 +2220,9 @@ bool CSteamNetworkingUtils::SetConfigValue( ESteamNetworkingConfigValue eValue, case k_ESteamNetworkingConfig_ConnectionUserData: { - // We only need special handling when modifying a connection - if ( eScopeType != k_ESteamNetworkingConfig_Connection ) + // We only need special handling when modifying a connection. + // Clearing it (NULL) falls through and is rejected by SetConfigValueTyped. + if ( eScopeType != k_ESteamNetworkingConfig_Connection || pValue == nullptr ) break; // Process the user argument, maybe performing type conversion diff --git a/tests/test_connection.cpp b/tests/test_connection.cpp index 22d50378..44284160 100644 --- a/tests/test_connection.cpp +++ b/tests/test_connection.cpp @@ -1227,6 +1227,9 @@ void Test_pipe() assert( infoBob.m_identityRemote == identAlice ); } + // Connection user data cannot be cleared. Passing NULL should fail, not crash. + assert( !SteamNetworkingUtils()->SetConfigValue( k_ESteamNetworkingConfig_ConnectionUserData, k_ESteamNetworkingConfig_Connection, hAlice, k_ESteamNetworkingConfig_Int64, nullptr ) ); + // Wire up to the global peer state used by TestNetworkConditions / PumpCallbacksAndMakeSureStillConnected. g_peerClient.Reset(); g_peerServer.Reset();