Fix a crash when attempting to upload a zero-length dump file (#83) r=mmentovai
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@71 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
4365e2fe41
commit
c297c50f83
1 changed files with 7 additions and 3 deletions
|
@ -226,7 +226,9 @@ bool HTTPUpload::GenerateRequestBody(const map<wstring, wstring> ¶meters,
|
|||
request_body->append("Content-Type: application/octet-stream\r\n");
|
||||
request_body->append("\r\n");
|
||||
|
||||
request_body->append(&(contents[0]), contents.size());
|
||||
if (!contents.empty()) {
|
||||
request_body->append(&(contents[0]), contents.size());
|
||||
}
|
||||
request_body->append("\r\n");
|
||||
request_body->append("--" + boundary_str + "--\r\n");
|
||||
return true;
|
||||
|
@ -249,8 +251,10 @@ void HTTPUpload::GetFileContents(const wstring &filename,
|
|||
file.seekg(0, ios::end);
|
||||
int length = file.tellg();
|
||||
contents->resize(length);
|
||||
file.seekg(0, ios::beg);
|
||||
file.read(&((*contents)[0]), length);
|
||||
if (length != 0) {
|
||||
file.seekg(0, ios::beg);
|
||||
file.read(&((*contents)[0]), length);
|
||||
}
|
||||
file.close();
|
||||
} else {
|
||||
contents->clear();
|
||||
|
|
Loading…
Reference in a new issue