summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-06-21 10:53:59 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-06-21 10:53:59 +0000
commit3bd11b2fa182c3e5f73e8fab06424ee9c8be12dd (patch)
treeb0a4711466dcd654122857e4d2fdf58276404cb9
parent1f9c4d5b83b314785cd9c83bbecec21cb00b192b (diff)
stop passing nullptr
-rw-r--r--document/src/vespa/document/util/bytebuffer.cpp4
-rw-r--r--vdslib/src/vespa/vdslib/container/searchresult.cpp4
-rw-r--r--vespalib/src/vespa/vespalib/data/memorydatastore.cpp4
3 files changed, 9 insertions, 3 deletions
diff --git a/document/src/vespa/document/util/bytebuffer.cpp b/document/src/vespa/document/util/bytebuffer.cpp
index 3d38aba6dae..8568ce44c5e 100644
--- a/document/src/vespa/document/util/bytebuffer.cpp
+++ b/document/src/vespa/document/util/bytebuffer.cpp
@@ -164,7 +164,9 @@ void ByteBuffer::getBytes(void *buffer, uint32_t count)
{
const char *v = getBufferAtPos();
incPos(count);
- memcpy(buffer, v, count);
+ if (count > 0) {
+ memcpy(buffer, v, count);
+ }
}
} // document
diff --git a/vdslib/src/vespa/vdslib/container/searchresult.cpp b/vdslib/src/vespa/vdslib/container/searchresult.cpp
index 12d5544d6ef..6989fbca8e0 100644
--- a/vdslib/src/vespa/vdslib/container/searchresult.cpp
+++ b/vdslib/src/vespa/vdslib/container/searchresult.cpp
@@ -63,7 +63,9 @@ size_t BlobContainer::append(const void * v, size_t sz)
if (getSize() > _blob.size()) {
_blob.realloc(getSize()*2);
}
- memcpy(_blob.str() + _offsets[index], v, sz);
+ if (sz > 0) {
+ memcpy(_blob.str() + _offsets[index], v, sz);
+ }
return index;
}
diff --git a/vespalib/src/vespa/vespalib/data/memorydatastore.cpp b/vespalib/src/vespa/vespalib/data/memorydatastore.cpp
index 6951da217c7..f7fa627ea7e 100644
--- a/vespalib/src/vespa/vespalib/data/memorydatastore.cpp
+++ b/vespalib/src/vespa/vespalib/data/memorydatastore.cpp
@@ -35,7 +35,9 @@ MemoryDataStore::push_back(const void * data, const size_t sz)
Reference ref(static_cast<char *>(buf.get()) + _writePos);
_writePos += sz;
guard.reset();
- memcpy(ref.data(), data, sz);
+ if (sz > 0) {
+ memcpy(ref.data(), data, sz);
+ }
return ref;
}