diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2006-12-02 18:17:53 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2006-12-02 18:17:53 (GMT) |
commit | 434d2292c5e595e68df4fe006ffe2086b6bde866 (patch) | |
tree | 2c51132851096e3a4ee9f6a94091399d7911dae3 /Source/CTest | |
parent | f67f158344d0202ad0460c221bcf5315c1bd2f6d (diff) | |
download | CMake-434d2292c5e595e68df4fe006ffe2086b6bde866.zip CMake-434d2292c5e595e68df4fe006ffe2086b6bde866.tar.gz CMake-434d2292c5e595e68df4fe006ffe2086b6bde866.tar.bz2 |
ENH: put checks on vector before referencing begin iterator
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 6fd24de..50ad8eb 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -200,14 +200,19 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() - << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" - << std::endl); + << local_file.c_str() + << std::endl + << " Error message was: " << error_buffer << std::endl + << " Curl output was: "; + // avoid dereference of empty vector + if(chunk.size()) + { + *this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size()); + cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } + *this->LogFile << std::endl; ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; @@ -379,14 +384,20 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << " Error when uploading file: " - << local_file.c_str() - << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" - << std::endl); + << local_file.c_str() + << std::endl + << " Error message was: " << error_buffer + << 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: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; @@ -499,13 +510,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); *this->LogFile << "\tTrigerring failed with error: " << error_buffer - << std::endl - << " Error message was: " << error_buffer << std::endl - << " Curl output was: " - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; - cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" - << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" - << std::endl); + << std::endl + << " Error message was: " << error_buffer + << std::endl; + if(chunk.size()) + { + *this->LogFile + << " Curl output was: " + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + } ::curl_easy_cleanup(curl); ::curl_global_cleanup(); return false; |