Don't leak memory when a resource fails to download in launcher

This commit is contained in:
UnknownShadow200 2019-07-29 22:53:16 +10:00
parent 186172e1d1
commit 1a9ada3590
4 changed files with 9 additions and 12 deletions

View File

@ -844,8 +844,8 @@ static void MainScreen_TickSignIn(struct MainScreen* s) {
LWebTask_Tick(&SignInTask.Base);
if (!SignInTask.Base.Completed) return;
if (SignInTask.Error.length) {
LLabel_SetText(&s->lblStatus, &SignInTask.Error);
if (SignInTask.Error) {
LLabel_SetConst(&s->lblStatus, SignInTask.Error);
LWidget_Redraw(&s->lblStatus);
} else if (SignInTask.Base.Success) {
/* website returns case correct username */

View File

@ -264,16 +264,12 @@ struct SignInTaskData SignInTask;
char userBuffer[STRING_SIZE];
static void SignInTask_LogError(const String* str) {
static const String userErr = String_FromConst("&cWrong username or password");
static const String verErr = String_FromConst("&cAccount verification required");
static const String unkErr = String_FromConst("&cUnknown error occurred");
if (String_CaselessEqualsConst(str, "username") || String_CaselessEqualsConst(str, "password")) {
SignInTask.Error = userErr;
SignInTask.Error = "&cWrong username or password";
} else if (String_CaselessEqualsConst(str, "verification")) {
SignInTask.Error = verErr;
SignInTask.Error = "&cAccount verification required";
} else if (str->length) {
SignInTask.Error = unkErr;
SignInTask.Error = "&cUnknown error occurred";
}
}
@ -302,7 +298,7 @@ void SignInTask_Run(const String* user, const String* pass) {
LWebTask_Reset(&SignInTask.Base);
String_InitArray(SignInTask.Username, userBuffer);
SignInTask.Error.length = 0;
SignInTask.Error = NULL;
String_InitArray(tmp, tmpBuffer);
SignInTask_Append(&tmp, "username=", user);

View File

@ -67,8 +67,8 @@ void GetTokenTask_Run(void);
extern struct SignInTaskData {
struct LWebTask Base;
String Username; /* Username to sign in as. Changed to case correct username. */
String Error; /* If sign in fails, the reason as to why. */
String Username; /* Username to sign in as. Changed to case correct username. */
const char* Error; /* If sign in fails, the reason as to why. */
} SignInTask;
void SignInTask_Run(const String* user, const String* pass);

View File

@ -763,6 +763,7 @@ CC_NOINLINE static bool Fetcher_Get(const String* id, struct HttpRequest* req) {
Fetcher_Result = req->Result;
Fetcher_StatusCode = req->StatusCode;
HttpRequest_Free(req);
Fetcher_Finish();
return false;
}