feat(util/object_serializer): protect against corrupted files
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
390a78a8d2
commit
c473a484bb
1 changed files with 3 additions and 1 deletions
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue