CancelFindSessions in FOnlineSessionNull needs IsValid()

The function FOnlineSessionNull::CancelFindSessions() has a bug.

bool FOnlineSessionNull::CancelFindSessions()
{
	uint32 Return = E_FAIL;
	if (CurrentSessionSearch->SearchState == EOnlineAsyncTaskState::InProgress)
	{
		// Make sure it's the right type
		Return = ERROR_SUCCESS;

		FinalizeLANSearch();

		CurrentSessionSearch->SearchState = EOnlineAsyncTaskState::Failed;
		CurrentSessionSearch = NULL;
	}
	else
	{
		UE_LOG_ONLINE(Warning, TEXT("Can't cancel a search that isn't in progress"));
	}

	if (Return != ERROR_IO_PENDING)
	{
		TriggerOnCancelFindSessionsCompleteDelegates(true);
	}

	return Return == ERROR_SUCCESS || Return == ERROR_IO_PENDING;
}

The CurrentSessionSearch is invalid. The code should test as :

if (CurrentSessionSearch.IsValid() && CurrentSessionSearch->SearchState == EOnlineAsyncTaskState::InProgress)

Otherwise if the function is called without having a search, an exception is thrown.

D.

Hey -

It seems as though you have found a solution for the problem you described. Would it be possible for you to enter a pull request for your fix to be implemented into the engine (https://github.com/EpicGames/UnrealEngine/compare?expand=1)? If you are unable to enter a pull request I can instead put in a feature request for the fix.

Cheers

Hi ,

For this version I’m using the zip and not Git Hub since the source code for 10.4 was only available through the zip. It was mentioned on the ue web site.
I think it is better to put a feature request for the fix.

Have a nice day,
D.

A feature request (UE-27656) has been entered to update the FOnlineSessionNull::CancelFindSessions() function.