diff --git a/src/Rtmp/amf.h b/src/Rtmp/amf.h index 402a1b59..9130451d 100644 --- a/src/Rtmp/amf.h +++ b/src/Rtmp/amf.h @@ -93,6 +93,10 @@ private: public: explicit DepthGuard(AMFDecoder &decoder); ~DepthGuard(); + DepthGuard(const DepthGuard &) = delete; + DepthGuard(DepthGuard &&) = delete; + DepthGuard &operator=(const DepthGuard &) = delete; + DepthGuard &operator=(DepthGuard &&) = delete; private: AMFDecoder &_decoder; diff --git a/tests/test_amf.cpp b/tests/test_amf.cpp index 7d0db34f..36c5e144 100644 --- a/tests/test_amf.cpp +++ b/tests/test_amf.cpp @@ -8,7 +8,7 @@ * may be found in the AUTHORS file in the root of the source tree. */ -#include +#include #include #include @@ -34,17 +34,24 @@ int main() { { BufferLikeString input(make_nested_object(64)); AMFDecoder decoder(input, 0); - assert(decoder.load().type() == AMF_OBJECT); + if (decoder.load().type() != AMF_OBJECT) { + cerr << "AMF object at the nesting limit was not decoded" << endl; + return 1; + } } { BufferLikeString input(make_nested_object(65)); AMFDecoder decoder(input, 0); + bool depth_rejected = false; try { decoder.load(); - assert(false); } catch (const runtime_error &ex) { - assert(string(ex.what()) == "Maximum AMF nesting depth exceeded"); + depth_rejected = string(ex.what()) == "Maximum AMF nesting depth exceeded"; + } + if (!depth_rejected) { + cerr << "AMF object beyond the nesting limit was not rejected" << endl; + return 2; } }