Fix log hook crash by checking string length, fix possible other crashes with downloading.
This commit is contained in:
parent
1c62192cd8
commit
e237640858
@ -176,7 +176,7 @@ int* __fastcall log_hook_v45(void* This, void* _EDX, int a2, int a3, void* a4, c
|
||||
|
||||
//std::cout << "logStr: " << logStr << std::endl;
|
||||
|
||||
if (logStr.compare(8, 9, "track_uri") == 0)
|
||||
if (logStr.length() >= 32 && logStr.compare(8, 9, "track_uri") == 0) // 19 + 13 = 32
|
||||
{
|
||||
if (logStr.compare(19, 13, "spotify:track") == 0)
|
||||
{
|
||||
@ -184,12 +184,13 @@ int* __fastcall log_hook_v45(void* This, void* _EDX, int a2, int a3, void* a4, c
|
||||
trackUriStr = logStr.substr(19, std::string::npos);
|
||||
newPosition = 0;
|
||||
}
|
||||
// TODO
|
||||
//else if (logStr.compare(19, 11, "spotify:ad") == 0) // Possibly this works?
|
||||
else
|
||||
/*else
|
||||
{
|
||||
std::cout << "Skipping ad: " << logStr.substr(19, std::string::npos) << std::endl;
|
||||
newPosition = 29000; // 29 seconds: duration of ad
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -216,7 +217,7 @@ void __fastcall fileIdWriter_hook_v45(void* This, void* _EDX, int* a2)
|
||||
}
|
||||
|
||||
int signalEmitterInitCount = 0;
|
||||
const int signalEmitterRequired = 5;
|
||||
const int signalEmitterRequired = 3;
|
||||
void __fastcall signalEmitter_hook_v45(void* This, void* _EDX, int a1, int a2)
|
||||
{
|
||||
//std::cout << "signalEmitter!!!" << std::endl << std::endl;
|
||||
|
@ -140,6 +140,12 @@ void Utils::DownloadSong(std::string fileId, std::string trackUri, std::string k
|
||||
{
|
||||
std::cout << "Downloading song..." << std::endl;
|
||||
|
||||
if (fileId.empty() || trackUri.empty() || key.empty() || authToken.empty())
|
||||
{
|
||||
std::cout << "Could not download song: missing fileId, trackUri, key, or authToken!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
/*std::cout << "fileId = " << fileId << std::endl;
|
||||
std::cout << "trackUri = " << trackUri << std::endl;
|
||||
std::cout << "key = " << key << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user