diff --git a/src/mgr/curlhttpt.cpp b/src/mgr/curlhttpt.cpp
index ad78e8d..cbebdb7 100644
--- a/src/mgr/curlhttpt.cpp
+++ b/src/mgr/curlhttpt.cpp
@@ -215,6 +215,7 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
 	if (!getURL("", dirURL, &dirBuf)) {
 		pBuf = strstr(dirBuf, "<a href=\"");//Find the next link to a possible file name.
 		while (pBuf != NULL) {
+			memset(possibleName, 0, 400);
 			pBuf += 9;//move to the start of the actual name.
 			pBufRes = (char *)strchr(pBuf, '\"');//Find the end of the possible file name
 			possibleNameLength = pBufRes - pBuf;
@@ -231,13 +232,13 @@ vector<struct DirEntry> CURLHTTPTransport::getDirList(const char *dirURL) {
 						fSize *= 1024;
 					else if (pBufRes[0] == 'M')
 						fSize *= 1048576;
+					pBuf = pBufRes;
 				}
 				struct DirEntry i;
 				i.name = possibleName;
 				i.size = (long unsigned int)fSize;
 				i.isDirectory = (possibleName[possibleNameLength-1] == '/');
 				dirList.push_back(i);
-				pBuf = pBufRes;
 			} else {
 				pBuf += possibleNameLength;
 			}
