@@ -323,7 +323,7 @@ public:
/// \brief Assignment operator
OutputBuffer& operator =(const OutputBuffer& other) {
uint8_t* newbuff(static_cast<uint8_t*>(malloc(other.allocated_)));
- if (newbuff == NULL) {
+ if (newbuff == NULL && other.allocated_ != 0) {
throw std::bad_alloc();
}
free(buffer_);
@@ -224,6 +224,8 @@ TEST_F(BufferTest, outputBufferZeroSize) {
EXPECT_NO_THROW({
OutputBuffer first(0);
OutputBuffer copy(first);
+ OutputBuffer second(0);
+ second = first;
});