The FTP root directory string is now copied so that the parameter doesn't have to live during the whole life of the program
This commit is contained in:
parent
714b167aef
commit
95ae6927e8
@ -27,7 +27,7 @@ class FTPServer : public TCPServer<T>
|
||||
{
|
||||
if (login != NULL)
|
||||
{
|
||||
if (strlen(login) > 0)
|
||||
if (strlen(login))
|
||||
{
|
||||
_login = (char *)malloc((sizeof(char) * strlen(login)) + 1);
|
||||
strcpy(_login, login);
|
||||
@ -36,7 +36,7 @@ class FTPServer : public TCPServer<T>
|
||||
|
||||
if (password != NULL)
|
||||
{
|
||||
if (strlen(password) > 0)
|
||||
if (strlen(password))
|
||||
{
|
||||
_password = (char *)malloc((sizeof(char) * strlen(password)) + 1);
|
||||
strcpy(_password, password);
|
||||
@ -53,7 +53,7 @@ class FTPServer : public TCPServer<T>
|
||||
virtual ~FTPServer()
|
||||
{
|
||||
_dataServer.stop();
|
||||
free(_login); free(_password);
|
||||
free(_login); free(_password); free(_FTPDir);
|
||||
}
|
||||
|
||||
virtual void stop()
|
||||
@ -67,7 +67,12 @@ class FTPServer : public TCPServer<T>
|
||||
|
||||
virtual void setFTPDir(const char *FTPDir)
|
||||
{
|
||||
_FTPDir = FTPDir;
|
||||
if(FTPDir)
|
||||
{
|
||||
free(_FTPDir);
|
||||
_FTPDir = (char *)malloc((strlen(FTPDir) * sizeof(char)) + 1);
|
||||
strcpy(_FTPDir, FTPDir);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -1028,7 +1033,7 @@ class FTPServer : public TCPServer<T>
|
||||
|
||||
char *_login;
|
||||
char *_password;
|
||||
const char *_FTPDir = NULL; //Pointer to constant string and char * const is a constant pointer to string
|
||||
char *_FTPDir = nullptr;
|
||||
uint16_t _dataPort;
|
||||
|
||||
WiFiServer _dataServer; //In passive mode, the FTP server opens two different ports (one for the commands and the other for the data stream)
|
||||
|
Loading…
Reference in New Issue
Block a user