diff --git a/matroska/KaxBlock.h b/matroska/KaxBlock.h index 6418ba4f..3dc4fb8e 100644 --- a/matroska/KaxBlock.h +++ b/matroska/KaxBlock.h @@ -68,11 +68,12 @@ class MATROSKA_DLL_API DataBuffer { { if (bInternalBuffer) { - myBuffer = new (std::nothrow) binary[mySize]; - if (myBuffer == nullptr) - bValidValue = false; - else + try { + myBuffer = new binary[mySize]; memcpy(myBuffer, aBuffer, mySize); + } catch (const std::bad_alloc &) { + bValidValue = false; + } } else myBuffer = aBuffer;