From 8e07c229862877d34d5b0c0b37e81bd06a95d117 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sat, 13 Apr 2019 23:19:06 +0900 Subject: [PATCH] Fixed cppcheck errors in ftplib.cpp. This solves #3. Signed-off-by: Michele Calgaro (cherry picked from commit d08b667172be0b6fdc3cdf7723205a7f5e12cfd4) --- src/ftplib.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 @@ int ftplib::FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir, cha { FtpClose(*nData); *nData = NULL; + free(ctrl); return -1; } @@ -851,9 +852,10 @@ int ftplib::FtpOpenPasv(netbuf *nControl, netbuf **nData, int mode, int dir, cha } 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");