fix(util/serializer): nontermination on corrupted files

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-01-07 14:21:54 -08:00
parent d5ddb186d9
commit f67eab000b

View file

@ -27,6 +27,10 @@ void serializer_core::write_int(int i) {
#define BIG_BUFFER 1024
void throw_corrupted_file() {
throw exception("corrupted binary file");
}
void serializer_core::write_double(double d) {
std::ostringstream out;
// TODO(Leo): the following code may miss precision.
@ -44,6 +48,8 @@ std::string deserializer_core::read_string() {
char c = m_in.get();
if (c == 0)
break;
if (c == EOF)
throw_corrupted_file();
r += c;
}
return r;
@ -70,8 +76,4 @@ double deserializer_core::read_double() {
in >> r;
return r;
}
void throw_corrupted_file() {
throw exception("corrupted binary file");
}
}