Skip to content

Commit

Permalink
ChaosMod/Mp3Manager: Properly construct wide str when unloading sounds
Browse files Browse the repository at this point in the history
Hot take: UB is bad
  • Loading branch information
pongo1231 committed Feb 8, 2024
1 parent 09c2992 commit a8e21fb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ChaosMod/Components/Mp3Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ Mp3Manager::~Mp3Manager()
{
for (const auto &soundFilePath : soundFileNames)
{
std::ostringstream oss;
oss << "close \"" << soundFilePath << "\"";
mciSendString(reinterpret_cast<LPCWSTR>(oss.str().c_str()), NULL, 0, NULL);
std::ostringstream tmp;
std::string tmpStr;
tmp << "close \"" << soundFilePath << "\"";
tmpStr = tmp.str();
std::wstring wTmpStr = { tmpStr.begin(), tmpStr.end() };
mciSendString(wTmpStr.c_str(), NULL, 0, NULL);
}
}

Expand Down

0 comments on commit a8e21fb

Please sign in to comment.