some workarounds for a potential libc++ bug

This commit is contained in:
Peter Thorson
2012-01-25 08:55:54 -06:00
parent 67a2cbcbed
commit 41412cebd9
2 changed files with 51 additions and 11 deletions

View File

@@ -61,7 +61,26 @@ public:
throw processor::exception("Message payload was too large.",processor::error::MESSAGE_TOO_BIG);
}
for (i = 0; i < size; ++i) {
i = 0;
while(input.good() && i < size) {
c = input.get();
if (input.good()) {
if (m_masking_index >= 0) {
c = c ^ m_masking_key[(m_masking_index++)%4];
}
m_payload.push_back(c);
i++;
} else if (input.eof()) {
break;
} else {
throw processor::exception("istream read error 2",
processor::error::FATAL_ERROR);
}
}
/*for (i = 0; i < size; ++i) {
if (input.good()) {
c = input.get();
@@ -81,7 +100,7 @@ public:
} else {
throw processor::exception("istream read error",processor::error::FATAL_ERROR);
}
}
}*/
// successfully read all bytes
return i;

View File

@@ -62,23 +62,44 @@ uint64_t data::process_payload(std::istream& input,uint64_t size) {
));
}
for (i = 0; i < size; ++i) {
// extract characters until size have been extracted or eof. return num ext
i = 0;
while(input.good() && i < size) {
c = input.get();
if (input.good()) {
c = input.get();
if (input.fail()) {
throw processor::exception("istream read error",
processor::error::FATAL_ERROR);
}
process_character(c);
i++;
} else if (input.eof()) {
break;
} else {
throw processor::exception("istream read error",
throw processor::exception("istream read error 2",
processor::error::FATAL_ERROR);
}
}
/*for (i = 0; i < size; ++i) {
if (input.good()) {
c = input.get();
process_character(c);
if (input.eof()) {
break;
}
if (input.fail()) {
throw processor::exception("istream read error 1",
processor::error::FATAL_ERROR);
}
} else if (input.eof()) {
break;
} else {
throw processor::exception("istream read error 2",
processor::error::FATAL_ERROR);
}
}*/
// successfully read all bytes
return i;
}
@@ -138,7 +159,7 @@ void data::set_prepared(bool b) {
}
bool data::get_prepared() const {
return m_prepared;
return m_prepared;
}
// This could be further optimized using methods that write directly into the