diff --git a/src/addhead.cpp b/src/addhead.cpp
index ac77da5..da7bccb 100644
--- a/src/addhead.cpp
+++ b/src/addhead.cpp
@@ -77,10 +77,10 @@ bool AdditionalHeader::Load(const char* file)
std::string line;
ADDHEAD *paddhead;
while(getline(AH, line)){
- if('#' == line[0]){
+ if(line.empty()){
continue;
}
- if(line.empty()){
+ if('#' == line[0]){
continue;
}
// load a line
diff --git a/src/curl.cpp b/src/curl.cpp
index 9790625..9720092 100644
--- a/src/curl.cpp
+++ b/src/curl.cpp
@@ -414,10 +414,10 @@ bool S3fsCurl::InitMimeType(const std::string& strFile)
S3fsCurl::mimeTypes.clear();
while(getline(MT, line)){
- if(line[0]=='#'){
+ if(line.empty()){
continue;
}
- if(line.empty()){
+ if(line[0]=='#'){
continue;
}
@@ -3302,7 +3302,7 @@ int S3fsCurl::PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t
requestHeaders = NULL;
responseHeaders.clear();
- if(-1 != start && 0 < size){
+ if(0 < size){
std::string range = "bytes=";
range += str(start);
range += "-";
@@ -3563,28 +3563,30 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
}
// make contents
- std::string postContent;
- postContent += "\n";
+ std::string* pPostContent = new std::string();
+ (*pPostContent) += "\n";
int cnt = 0;
for(etaglist_t::iterator it = parts.begin(); it != parts.end(); ++it, ++cnt){
if(it->empty()){
S3FS_PRN_ERR("%d file part is not finished uploading.", cnt + 1);
+ delete pPostContent;
return -EIO;
}
- postContent += "\n";
- postContent += " " + str(cnt + 1) + "\n";
- postContent += " " + *it + "\n";
- postContent += "\n";
+ (*pPostContent) += "\n";
+ (*pPostContent) += " " + str(cnt + 1) + "\n";
+ (*pPostContent) += " " + *it + "\n";
+ (*pPostContent) += "\n";
}
- postContent += "\n";
+ (*pPostContent) += "\n";
// set postdata
- postdata = reinterpret_cast(postContent.c_str());
+ postdata = reinterpret_cast(pPostContent->c_str());
b_postdata = postdata;
- postdata_remaining = postContent.size(); // without null
+ postdata_remaining = pPostContent->size(); // without null
b_postdata_remaining = postdata_remaining;
if(!CreateCurlHandle()){
+ delete pPostContent;
return -EIO;
}
std::string resource;
@@ -3623,6 +3625,7 @@ int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const std::string&
int result = RequestPerform();
bodydata.Clear();
postdata = NULL;
+ delete pPostContent;
return result;
}