summaryrefslogtreecommitdiff
path: root/buffer.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2008-03-03 17:59:57 +0000
committerChristian Pointner <equinox@anytun.org>2008-03-03 17:59:57 +0000
commit30dbbc65bd3684b9cefa000069b611a608f4be3e (patch)
tree68614a0ccd2a68c3fcd90b5a7652f798f795d50e /buffer.cpp
parentadded showtable (diff)
some bugfixes
added support for authentication
Diffstat (limited to 'buffer.cpp')
-rw-r--r--buffer.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/buffer.cpp b/buffer.cpp
index 675383b..250a806 100644
--- a/buffer.cpp
+++ b/buffer.cpp
@@ -56,6 +56,12 @@ Buffer::Buffer(u_int32_t length, bool allow_realloc) : length_(length), real_len
Buffer::Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc) : length_(length), real_length_(length + Buffer::OVER_SIZE_),
allow_realloc_(allow_realloc)
{
+ if(!data) {
+ length_ = 0;
+ real_length_ = 0;
+ return;
+ }
+
buf_ = new u_int8_t[real_length_];
if(!buf_) {
length_ = 0;
@@ -182,11 +188,11 @@ void Buffer::setLength(u_int32_t new_length)
old_buf = &buf_[old_length];
std::memset(old_buf, 0, real_length_ - old_length);
-
- reinit();
}
else
length_ = new_length;
+
+ reinit();
}