From c473a484bb0aecf3314284e7f8822216ce006792 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Mon, 30 Dec 2013 17:58:20 -0800 Subject: [PATCH] feat(util/object_serializer): protect against corrupted files Signed-off-by: Leonardo de Moura --- src/util/object_serializer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/object_serializer.h b/src/util/object_serializer.h index 015147f68..c111de4af 100644 --- a/src/util/object_serializer.h +++ b/src/util/object_serializer.h @@ -7,6 +7,7 @@ Author: Leonardo de Moura #pragma once #include #include +#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]; } }