ENH: put checks on vector before referencing begin iterator

This commit is contained in:
Bill Hoffman 2006-12-02 13:17:53 -05:00
parent f67f158344
commit 434d2292c5
1 changed files with 39 additions and 23 deletions

View File

@ -203,11 +203,16 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
<< local_file.c_str() << local_file.c_str()
<< std::endl << std::endl
<< " Error message was: " << error_buffer << std::endl << " Error message was: " << error_buffer << std::endl
<< " Curl output was: " << " Curl output was: ";
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; // avoid dereference of empty vector
if(chunk.size())
{
*this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl); << std::endl);
}
*this->LogFile << std::endl;
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
@ -381,12 +386,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
*this->LogFile << " Error when uploading file: " *this->LogFile << " Error when uploading file: "
<< local_file.c_str() << local_file.c_str()
<< std::endl << std::endl
<< " Error message was: " << error_buffer << std::endl << " Error message was: " << error_buffer
<< " Curl output was: " << std::endl;
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; // avoid deref of begin for zero size array
if(chunk.size())
{
*this->LogFile << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
<< std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl); << std::endl);
}
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;
@ -500,12 +511,17 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
<< error_buffer << std::endl); << error_buffer << std::endl);
*this->LogFile << "\tTrigerring failed with error: " << error_buffer *this->LogFile << "\tTrigerring failed with error: " << error_buffer
<< std::endl << std::endl
<< " Error message was: " << error_buffer << std::endl << " Error message was: " << error_buffer
<< std::endl;
if(chunk.size())
{
*this->LogFile
<< " Curl output was: " << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl); << std::endl);
}
::curl_easy_cleanup(curl); ::curl_easy_cleanup(curl);
::curl_global_cleanup(); ::curl_global_cleanup();
return false; return false;