aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libtransport/src/hicn/transport/core/connector.h3
-rw-r--r--libtransport/src/hicn/transport/utils/membuf.h3
2 files changed, 5 insertions, 1 deletions
diff --git a/libtransport/src/hicn/transport/core/connector.h b/libtransport/src/hicn/transport/core/connector.h
index c5250486c..ae82ee973 100644
--- a/libtransport/src/hicn/transport/core/connector.h
+++ b/libtransport/src/hicn/transport/core/connector.h
@@ -76,7 +76,8 @@ class Connector {
result.second->separateChain(result.second->next(),
result.second->prev());
}
- result.second->clear();
+
+ result.second->trimEnd(result.second->length());
return std::move(result.second);
}
diff --git a/libtransport/src/hicn/transport/utils/membuf.h b/libtransport/src/hicn/transport/utils/membuf.h
index 5a10d4182..a150483b1 100644
--- a/libtransport/src/hicn/transport/utils/membuf.h
+++ b/libtransport/src/hicn/transport/utils/membuf.h
@@ -225,6 +225,9 @@ class MemBuf {
void trimEnd(std::size_t amount) { length_ -= amount; }
+ // Never call clear on cloned membuf sharing different
+ // portions of the same underlying buffer.
+ // Use the trim functions instead.
void clear() {
data_ = writableBuffer();
length_ = 0;