From 04c4679074e505adcdd1611676baab0c06466934 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Thu, 1 Mar 2018 11:52:43 +0100 Subject: Check that FIGs don't write too many bytes --- src/fig/FIGCarousel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/fig') diff --git a/src/fig/FIGCarousel.cpp b/src/fig/FIGCarousel.cpp index e32ea39..bfd87c8 100644 --- a/src/fig/FIGCarousel.cpp +++ b/src/fig/FIGCarousel.cpp @@ -290,7 +290,15 @@ size_t FIGCarousel::carousel( ss << "Assertion error: FIG" << fig_el->fig->figtype() << "/" << fig_el->fig->figextension() << " did not write enough data: (" << written << ")"; - throw std::runtime_error(ss.str()); + throw std::logic_error(ss.str()); + } + else if (written > available_size) { + std::stringstream ss; + ss << "Assertion error: FIG" << fig_el->fig->figtype() << "/" << + fig_el->fig->figextension() << + " wrote " << written << " bytes, but only " << + available_size << " available!"; + throw std::logic_error(ss.str()); } if (written > 2) { -- cgit v1.2.3