audio/internal/oboe: Bug fix: Use-after-free of a player

In theory, a closed player was used unexpectedly by these steps:

  1. Suspend is called by switching the application
  2. Player_Close is called
  3. Resume is called by reactivating the application

The set of GetPlayersToResume() had a closed player and the trying to
play it caused the use-after-free problem.

This changes fixes the issue by removing the player from the set of
GetPlayerToResume() when closing it. iOS version already has the logic
to remove the player appropriately.

Updates #1645
Closes #1646
This commit is contained in:
Hajime Hoshi 2021-05-16 02:20:58 +09:00
parent 5f773a3277
commit 2edb286ec4

View File

@ -141,6 +141,7 @@ public:
std::lock_guard<std::mutex> lock(PlayersMutex()); std::lock_guard<std::mutex> lock(PlayersMutex());
const char* msg = Close(); const char* msg = Close();
GetPlayers().erase(this); GetPlayers().erase(this);
GetPlayersToResume().erase(this);
return msg; return msg;
} }