BIND 10 trac536, updated. 865d62e9e58a3acf270f163a75ba713c134d82d2 Added check for another malloc() that might try to allocate 0 bytes.

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Apr 7 13:17:21 UTC 2011


The branch, trac536 has been updated
       via  865d62e9e58a3acf270f163a75ba713c134d82d2 (commit)
      from  aac391dda57b88507b8b10ac4bd1b068d3701b2d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 865d62e9e58a3acf270f163a75ba713c134d82d2
Author: Shane Kerr <shane at isc.org>
Date:   Thu Apr 7 15:16:46 2011 +0200

    Added check for another malloc() that might try to allocate 0 bytes.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/dns/buffer.h                 |    2 +-
 src/lib/dns/tests/buffer_unittest.cc |    2 ++
 2 files changed, 3 insertions(+), 1 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/buffer.h b/src/lib/dns/buffer.h
index 1739d9d..caf1b62 100644
--- a/src/lib/dns/buffer.h
+++ b/src/lib/dns/buffer.h
@@ -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_);
diff --git a/src/lib/dns/tests/buffer_unittest.cc b/src/lib/dns/tests/buffer_unittest.cc
index bb6c366..65e1e96 100644
--- a/src/lib/dns/tests/buffer_unittest.cc
+++ b/src/lib/dns/tests/buffer_unittest.cc
@@ -224,6 +224,8 @@ TEST_F(BufferTest, outputBufferZeroSize) {
     EXPECT_NO_THROW({
         OutputBuffer first(0);
         OutputBuffer copy(first);
+        OutputBuffer second(0);
+        second = first;
     });
 }
 




More information about the bind10-changes mailing list