Branch: master

d08b6671 2019-04-13 14:19:06 Michele Calgaro
Fixed cppcheck errors in ftplib.cpp. This solves #3.

Signed-off-by: Michele Calgaro <michele.calgaro@...>
M src/ftplib.cpp

src/ftplib.cpp

diff --git a/src/ftplib.cpp b/src/ftplib.cpp
index def17f9..94d5fff 100644
--- a/src/ftplib.cpp
+++ b/src/ftplib.cpp
@@ -756,6 +756,7 @@
 	{
 		FtpClose(*nData);
 		*nData = NULL;
+		free(ctrl);
 		return -1;
 	}
 
@@ -851,9 +852,10 @@
 	}
 
 	if (nControl->dir != FTPLIB_CONTROL) return -1;
-	sprintf(cmd,"%s\r\n",cmd);
-	if (nControl->tlsctrl) ret = SSL_write(nControl->ssl,cmd,strlen(cmd));
-	else ret = write(nControl->handle,cmd,strlen(cmd));
+	char buf[256];
+	sprintf(buf,"%s\r\n",cmd);
+	if (nControl->tlsctrl) ret = SSL_write(nControl->ssl,buf,strlen(buf));
+	else ret = write(nControl->handle,buf,strlen(buf));
 	if (ret <= 0)
 	{
 		perror("write");