fixes character processing bug when using LLVM libc++

This commit is contained in:
Peter Thorson
2012-01-24 09:16:50 -06:00
parent 4e6676ccca
commit f19d11a002
3 changed files with 16 additions and 21 deletions

View File

@@ -63,26 +63,23 @@ public:
for (i = 0; i < size; ++i) {
if (input.good()) {
c = input.get();
} else if (input.eof()) {
break;
} else {
// istream read error? throw?
throw processor::exception("istream read error",processor::error::FATAL_ERROR);
}
if (input.good()) {
// process c
c = input.get();
if (input.fail()) {
throw processor::exception("istream read error",
processor::error::FATAL_ERROR);
}
if (m_masking_index >= 0) {
c = c ^ m_masking_key[(m_masking_index++)%4];
}
// add c to payload
m_payload.push_back(c);
} else if (input.eof()) {
break;
} else {
// istream read error? throw?
throw processor::exception("istream read error",processor::error::FATAL_ERROR);
throw processor::exception("istream read error",processor::error::FATAL_ERROR);
}
}

View File

@@ -65,19 +65,15 @@ uint64_t data::process_payload(std::istream& input,uint64_t size) {
for (i = 0; i < size; ++i) {
if (input.good()) {
c = input.get();
} else if (input.eof()) {
break;
} else {
// istream read error? throw?
throw processor::exception("istream read error",
processor::error::FATAL_ERROR);
}
if (input.good()) {
if (input.fail()) {
throw processor::exception("istream read error",
processor::error::FATAL_ERROR);
}
process_character(c);
} else if (input.eof()) {
break;
} else {
// istream read error? throw?
throw processor::exception("istream read error",
processor::error::FATAL_ERROR);
}
@@ -117,6 +113,7 @@ void data::complete() {
throw processor::exception("Invalid UTF8 data",processor::error::PAYLOAD_VIOLATION);
}
}
}
void data::validate_payload() {

View File

@@ -76,6 +76,7 @@ void hybi_header::consume(std::istream& input) {
default:
break;
}
//std::cout << "header so far: " << to_hex(std::string(m_header,MAX_HEADER_LENGTH)) << std::endl;
}
uint64_t hybi_header::get_bytes_needed() const {
return m_bytes_needed;