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
|
#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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue