feat(util/object_serializer): protect against corrupted files

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-12-30 17:58:20 -08:00
parent 390a78a8d2
commit c473a484bb

View file

@ -7,6 +7,7 @@ Author: Leonardo de Moura
#pragma once #pragma once
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "util/exception.h"
#include "util/serializer.h" #include "util/serializer.h"
#ifndef LEAN_OBJECT_SERIALIZER_BUCKET_SIZE #ifndef LEAN_OBJECT_SERIALIZER_BUCKET_SIZE
@ -60,7 +61,8 @@ public:
return r; return r;
} else { } else {
unsigned i = d.read_unsigned(); unsigned i = d.read_unsigned();
lean_assert(i < m_table.size()); if (i >= m_table.size())
throw exception("corrupted binary file");
return m_table[i]; return m_table[i];
} }
} }