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
#include <unordered_map>
#include <vector>
#include "util/exception.h"
#include "util/serializer.h"
#ifndef LEAN_OBJECT_SERIALIZER_BUCKET_SIZE
@ -60,7 +61,8 @@ public:
return r;
} else {
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];
}
}