Skip to content

Commit 1ac18e1

Browse files
committed
Merge pull request esp8266#1119 from me-no-dev/www-basic-auth
memory housekeeping
2 parents fe6892a + 4ca084e commit 1ac18e1

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,25 @@ bool ESP8266WebServer::authenticate(const char * username, const char * password
8787
authReq.trim();
8888
char toencodeLen = strlen(username)+strlen(password)+1;
8989
char *toencode = new char[toencodeLen];
90-
if(toencode == NULL)
90+
if(toencode == NULL){
91+
authReq = String();
9192
return false;
93+
}
9294
char *encoded = new char[base64_encode_expected_len(toencodeLen)+1];
93-
if(encoded == NULL)
95+
if(encoded == NULL){
96+
authReq = String();
97+
delete[] toencode;
9498
return false;
95-
99+
}
96100
sprintf(toencode, "%s:%s", username, password);
97101
if(base64_encode_chars(toencode, toencodeLen, encoded) > 0 && authReq.equals(encoded)){
98102
authReq = String();
103+
delete[] toencode;
104+
delete[] encoded;
99105
return true;
100106
}
107+
delete[] toencode;
108+
delete[] encoded;
101109
}
102110
authReq = String();
103111
}

0 commit comments

Comments
 (0)