diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-03-01 11:52:43 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-03-01 11:52:43 +0100 |
commit | 04c4679074e505adcdd1611676baab0c06466934 (patch) | |
tree | f2cfb919b615c98adb79f6924cd3cf60a17a2260 /src | |
parent | 715705de018f815b3695af983c8d6623ba73a9ae (diff) | |
download | dabmux-04c4679074e505adcdd1611676baab0c06466934.tar.gz dabmux-04c4679074e505adcdd1611676baab0c06466934.tar.bz2 dabmux-04c4679074e505adcdd1611676baab0c06466934.zip |
Check that FIGs don't write too many bytes
Diffstat (limited to 'src')
-rw-r--r-- | src/DabMux.cpp | 4 | ||||
-rw-r--r-- | src/fig/FIGCarousel.cpp | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/DabMux.cpp b/src/DabMux.cpp index c0f5ad0..3185fb3 100644 --- a/src/DabMux.cpp +++ b/src/DabMux.cpp @@ -529,6 +529,10 @@ int main(int argc, char *argv[]) etiLog.level(error) << "Caught out of range exception : " << except.what(); returnCode = 1; } + catch (const std::logic_error& except) { + etiLog.level(error) << "Caught logic error : " << except.what(); + returnCode = 2; + } catch (const std::runtime_error& except) { etiLog.level(error) << "Caught runtime error : " << except.what(); returnCode = 2; 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) { |