diff options
17 files changed, 95 insertions, 209 deletions
diff --git a/fnet/src/tests/frt/method_pt/method_pt.cpp b/fnet/src/tests/frt/method_pt/method_pt.cpp index 3ce3c3062af..bc42a31d91b 100644 --- a/fnet/src/tests/frt/method_pt/method_pt.cpp +++ b/fnet/src/tests/frt/method_pt/method_pt.cpp @@ -6,14 +6,8 @@ #include <vespa/fnet/frt/rpcrequest.h> class Test; class SimpleHandler; - -class MediumHandler1; -class MediumHandler2; -class MediumHandler3; - -class ComplexHandler1; -class ComplexHandler2; -class ComplexHandler3; +class MediumHandler; +class ComplexHandler; //------------------------------------------------------------- @@ -23,12 +17,8 @@ std::unique_ptr<fnet::frt::StandaloneFRT> _server; FRT_Supervisor *_supervisor; FRT_Target *_target; SimpleHandler *_simpleHandler; -MediumHandler1 *_mediumHandler1; -MediumHandler2 *_mediumHandler2; -MediumHandler3 *_mediumHandler3; -ComplexHandler1 *_complexHandler1; -ComplexHandler2 *_complexHandler2; -ComplexHandler3 *_complexHandler3; +MediumHandler *_mediumHandler; +ComplexHandler *_complexHandler; bool _mediumHandlerOK; bool _complexHandlerOK; @@ -115,31 +105,9 @@ public: //------------------------------------------------------------- -class MediumHandler1 : public FRT_Invokable, - public MediumA, - public MediumB -{ -public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); -}; - - -class MediumHandler2 : public MediumA, - public FRT_Invokable, - public MediumB -{ -public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); -}; - - -class MediumHandler3 : public MediumA, - public MediumB, - public FRT_Invokable +class MediumHandler : public FRT_Invokable, + public MediumA, + public MediumB { public: void foo() override {} @@ -149,31 +117,9 @@ public: //------------------------------------------------------------- -class ComplexHandler1 : public FRT_Invokable, - public ComplexA, - public ComplexB -{ -public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); -}; - - -class ComplexHandler2 : public ComplexA, - public FRT_Invokable, - public ComplexB -{ -public: - void foo() override {} - void bar() override {} - void RPC_Method(FRT_RPCRequest *req); -}; - - -class ComplexHandler3 : public ComplexA, - public ComplexB, - public FRT_Invokable +class ComplexHandler : public FRT_Invokable, + public ComplexA, + public ComplexB { public: void foo() override {} @@ -187,21 +133,13 @@ void initTest() { _server = std::make_unique<fnet::frt::StandaloneFRT>(); _supervisor = &_server->supervisor(); _simpleHandler = new SimpleHandler(); - _mediumHandler1 = new MediumHandler1(); - _mediumHandler2 = new MediumHandler2(); - _mediumHandler3 = new MediumHandler3(); - _complexHandler1 = new ComplexHandler1(); - _complexHandler2 = new ComplexHandler2(); - _complexHandler3 = new ComplexHandler3(); + _mediumHandler = new MediumHandler(); + _complexHandler = new ComplexHandler(); ASSERT_TRUE(_supervisor != nullptr); ASSERT_TRUE(_simpleHandler != nullptr); - ASSERT_TRUE(_mediumHandler1 != nullptr); - ASSERT_TRUE(_mediumHandler2 != nullptr); - ASSERT_TRUE(_mediumHandler3 != nullptr); - ASSERT_TRUE(_complexHandler1 != nullptr); - ASSERT_TRUE(_complexHandler2 != nullptr); - ASSERT_TRUE(_complexHandler3 != nullptr); + ASSERT_TRUE(_mediumHandler != nullptr); + ASSERT_TRUE(_complexHandler != nullptr); ASSERT_TRUE(_supervisor->Listen(0)); std::string spec = vespalib::make_string("tcp/localhost:%d", @@ -219,31 +157,15 @@ void initTest() { //------------------------------------------------------------------- - rb.DefineMethod("mediumMethod1", "", "", - FRT_METHOD(MediumHandler1::RPC_Method), - _mediumHandler1); - - rb.DefineMethod("mediumMethod2", "", "", - FRT_METHOD(MediumHandler2::RPC_Method), - _mediumHandler2); - - rb.DefineMethod("mediumMethod3", "", "", - FRT_METHOD(MediumHandler3::RPC_Method), - _mediumHandler3); + rb.DefineMethod("mediumMethod", "", "", + FRT_METHOD(MediumHandler::RPC_Method), + _mediumHandler); //------------------------------------------------------------------- - rb.DefineMethod("complexMethod1", "", "", - FRT_METHOD(ComplexHandler1::RPC_Method), - _complexHandler1); - - rb.DefineMethod("complexMethod2", "", "", - FRT_METHOD(ComplexHandler2::RPC_Method), - _complexHandler2); - - rb.DefineMethod("complexMethod3", "", "", - FRT_METHOD(ComplexHandler3::RPC_Method), - _complexHandler3); + rb.DefineMethod("complexMethod", "", "", + FRT_METHOD(ComplexHandler::RPC_Method), + _complexHandler); //------------------------------------------------------------------- @@ -253,12 +175,8 @@ void initTest() { void finiTest() { - delete _complexHandler1; - delete _complexHandler2; - delete _complexHandler3; - delete _mediumHandler1; - delete _mediumHandler2; - delete _mediumHandler3; + delete _complexHandler; + delete _mediumHandler; delete _simpleHandler; _target->SubRef(); _server.reset(); @@ -275,19 +193,7 @@ TEST("method pt") { req->SubRef(); req = _supervisor->AllocRPCRequest(); - req->SetMethodName("mediumMethod1"); - _target->InvokeSync(req, 60.0); - EXPECT_TRUE(!req->IsError()); - - req->SubRef(); - req = _supervisor->AllocRPCRequest(); - req->SetMethodName("mediumMethod2"); - _target->InvokeSync(req, 60.0); - EXPECT_TRUE(!req->IsError()); - - req->SubRef(); - req = _supervisor->AllocRPCRequest(); - req->SetMethodName("mediumMethod3"); + req->SetMethodName("mediumMethod"); _target->InvokeSync(req, 60.0); EXPECT_TRUE(!req->IsError()); @@ -295,19 +201,7 @@ TEST("method pt") { req->SubRef(); req = _supervisor->AllocRPCRequest(); - req->SetMethodName("complexMethod1"); - _target->InvokeSync(req, 60.0); - EXPECT_TRUE(!req->IsError()); - - req->SubRef(); - req = _supervisor->AllocRPCRequest(); - req->SetMethodName("complexMethod2"); - _target->InvokeSync(req, 60.0); - EXPECT_TRUE(!req->IsError()); - - req->SubRef(); - req = _supervisor->AllocRPCRequest(); - req->SetMethodName("complexMethod3"); + req->SetMethodName("complexMethod"); _target->InvokeSync(req, 60.0); EXPECT_TRUE(!req->IsError()); @@ -338,57 +232,21 @@ SimpleHandler::RPC_Method(FRT_RPCRequest *req) //------------------------------------------------------------- void -MediumHandler1::RPC_Method(FRT_RPCRequest *req) -{ - (void) req; - _mediumHandlerOK = (_mediumHandlerOK && - this == _mediumHandler1); -} - - -void -MediumHandler2::RPC_Method(FRT_RPCRequest *req) +MediumHandler::RPC_Method(FRT_RPCRequest *req) { (void) req; _mediumHandlerOK = (_mediumHandlerOK && - this == _mediumHandler2); -} - - -void -MediumHandler3::RPC_Method(FRT_RPCRequest *req) -{ - (void) req; - _mediumHandlerOK = (_mediumHandlerOK && - this == _mediumHandler3); + this == _mediumHandler); } //------------------------------------------------------------- void -ComplexHandler1::RPC_Method(FRT_RPCRequest *req) -{ - (void) req; - _complexHandlerOK = (_complexHandlerOK && - this == _complexHandler1); -} - - -void -ComplexHandler2::RPC_Method(FRT_RPCRequest *req) -{ - (void) req; - _complexHandlerOK = (_complexHandlerOK && - this == _complexHandler2); -} - - -void -ComplexHandler3::RPC_Method(FRT_RPCRequest *req) +ComplexHandler::RPC_Method(FRT_RPCRequest *req) { (void) req; _complexHandlerOK = (_complexHandlerOK && - this == _complexHandler3); + this == _complexHandler); } //------------------------------------------------------------- diff --git a/fnet/src/tests/frt/rpc/sharedblob.cpp b/fnet/src/tests/frt/rpc/sharedblob.cpp index 90cfa63fbdb..2ccb44d03cb 100644 --- a/fnet/src/tests/frt/rpc/sharedblob.cpp +++ b/fnet/src/tests/frt/rpc/sharedblob.cpp @@ -29,20 +29,28 @@ struct Data uint32_t len; Data(const char *pt, uint32_t l) : buf(new char[l]), len(l) { - memcpy(buf, pt, len); + if (len > 0) { + memcpy(buf, pt, len); + } } Data(uint32_t l, char c) : buf(new char[l]), len(l) { - memset(buf, c, len); + if (len > 0) { + memset(buf, c, len); + } } Data(const Data &rhs) : buf(new char[rhs.len]), len(rhs.len) { - memcpy(buf, rhs.buf, len); + if (len > 0) { + memcpy(buf, rhs.buf, len); + } } Data &operator=(const Data &rhs) { if (this != &rhs) { delete [] buf; buf = new char[rhs.len]; len = rhs.len; - memcpy(buf, rhs.buf, len); + if (len > 0) { + memcpy(buf, rhs.buf, len); + } } return *this; } diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index c0d291ca695..b1b5f45a8fa 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -74,10 +74,10 @@ private: public: Reader(std::unique_ptr<FastOS_FileInterface> datFile) : _datFile(std::move(datFile)), - _lidReader(_datFile.file()), - _gidReader(_datFile.file()), - _bucketUsedBitsReader(_datFile.file()), - _timestampReader(_datFile.file()), + _lidReader(&_datFile.file()), + _gidReader(&_datFile.file()), + _bucketUsedBitsReader(&_datFile.file()), + _timestampReader(&_datFile.file()), _docIdLimit(0) { _docIdLimit = _datFile.header().getTag(DOCID_LIMIT).asInteger(); diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index ee1680bbd9a..bf0b74b0003 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -100,7 +100,7 @@ private: public: MockIndexLoader(int& index_value, FastOS_FileInterface& file) : _index_value(index_value), - _reader(file) + _reader(&file) {} bool load_next() override { _index_value = _reader.readHostOrder(); diff --git a/searchlib/src/tests/sortspec/multilevelsort.cpp b/searchlib/src/tests/sortspec/multilevelsort.cpp index 005fe6bd9d5..82bdf99ab2c 100644 --- a/searchlib/src/tests/sortspec/multilevelsort.cpp +++ b/searchlib/src/tests/sortspec/multilevelsort.cpp @@ -56,7 +56,7 @@ private: T getRandomValue() { T min = std::numeric_limits<T>::min(); T max = std::numeric_limits<T>::max(); - return min + static_cast<T>(double(max - min) * (((float)rand() / (float)RAND_MAX))); + return static_cast<T>(double(min) + (double(max) - double(min)) * (double(rand()) / double(RAND_MAX))); } template<typename T> void fill(IntegerAttribute *attr, uint32_t size, uint32_t unique = 0); diff --git a/searchlib/src/vespa/searchlib/attribute/primitivereader.h b/searchlib/src/vespa/searchlib/attribute/primitivereader.h index 12eac275f8a..613065260ad 100644 --- a/searchlib/src/vespa/searchlib/attribute/primitivereader.h +++ b/searchlib/src/vespa/searchlib/attribute/primitivereader.h @@ -13,7 +13,7 @@ namespace search { public: PrimitiveReader(AttributeVector &attr) : ReaderBase(attr), - _datReader(_datFile.file()) + _datReader(&_datFile.file()) { } virtual ~PrimitiveReader() { } diff --git a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp index d023d9b56b1..8dd1a466fb5 100644 --- a/searchlib/src/vespa/searchlib/attribute/readerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/readerbase.cpp @@ -32,9 +32,9 @@ ReaderBase::ReaderBase(AttributeVector &attr) attribute::LoadUtils::openWeight(attr) : std::unique_ptr<Fast_BufferedFile>()), _idxFile(attr.hasMultiValue() ? attribute::LoadUtils::openIDX(attr) : std::unique_ptr<Fast_BufferedFile>()), - _weightReader(_weightFile.file()), - _idxReader(_idxFile.file()), - _enumReader(_datFile.file()), + _weightReader(_weightFile.valid() ? &_weightFile.file() : nullptr), + _idxReader(_idxFile.valid() ? &_idxFile.file() : nullptr), + _enumReader(&_datFile.file()), _currIdx(0), _createSerialNum(0u), _fixedWidth(attr.getFixedWidth()), diff --git a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp index 9e3e6c9e46c..79a6742f9da 100644 --- a/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp +++ b/searchlib/src/vespa/searchlib/docstore/chunkformat.cpp @@ -38,8 +38,8 @@ ChunkFormat::pack(uint64_t lastSerial, vespalib::DataBuffer & compressed, const compressed.getData()[oldPos] = type; } if (includeSerializedSize()) { - const uint32_t serializedSize = compressed.getDataLen()+4; - *reinterpret_cast<uint32_t *>(compressed.getData() + serializedSizePos) = htonl(serializedSize); + const uint32_t serializedSize = htonl(compressed.getDataLen()+4); + memcpy(compressed.getData() + serializedSizePos, &serializedSize, sizeof(serializedSize)); } uint32_t crc = computeCrc(compressed.getData(), compressed.getDataLen()); compressed.writeInt32(crc); diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index f625a2b7fd2..ae1d2c16960 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -48,17 +48,19 @@ SimpleQueryStackDumpIterator::read_stringref(const char *&p) uint64_t SimpleQueryStackDumpIterator::readUint64(const char *&p) { - uint64_t l = vespalib::nbo::n2h(*(const uint64_t *)(const void *)p); - p += sizeof(uint64_t); - return l; + uint64_t value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); } double SimpleQueryStackDumpIterator::read_double(const char *&p) { - double result = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); - p += sizeof(double); - return result; + double value; + memcpy(&value, p, sizeof(value)); + p += sizeof(value); + return vespalib::nbo::n2h(value); } uint64_t diff --git a/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h b/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h index 45fcf5524d2..adad87d8cfe 100644 --- a/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h +++ b/searchlib/src/vespa/searchlib/tensor/blob_sequence_reader.h @@ -17,7 +17,7 @@ private: public: BlobSequenceReader(AttributeVector &attr) : ReaderBase(attr), - _sizeReader(_datFile.file()) + _sizeReader(&_datFile.file()) { } uint32_t getNextSize() { return _sizeReader.readHostOrder(); } void readBlob(void *buf, size_t len); diff --git a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp index 24bfacb8c5a..e82f31df38e 100644 --- a/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp +++ b/searchlib/src/vespa/searchlib/tensor/hnsw_index.cpp @@ -685,7 +685,7 @@ HnswIndex::make_loader(FastOS_FileInterface& file) assert(get_entry_docid() == 0); // cannot load after index has data using ReaderType = FileReader<uint32_t>; using LoaderType = HnswIndexLoader<ReaderType>; - return std::make_unique<LoaderType>(_graph, std::make_unique<ReaderType>(file)); + return std::make_unique<LoaderType>(_graph, std::make_unique<ReaderType>(&file)); } struct NeighborsByDocId { diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h index 7f17adc99f7..f7ea80c9248 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.h +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.h @@ -18,7 +18,7 @@ namespace search::transactionlog { class TransLogServerExplorer; class Domain; -class TransLogServer : public document::Runnable, private FRT_Invokable, public WriterFactory +class TransLogServer : private FRT_Invokable, public document::Runnable, public WriterFactory { public: friend class TransLogServerExplorer; diff --git a/searchlib/src/vespa/searchlib/util/fileutil.cpp b/searchlib/src/vespa/searchlib/util/fileutil.cpp index e85e792f492..7d65e298767 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.cpp +++ b/searchlib/src/vespa/searchlib/util/fileutil.cpp @@ -109,9 +109,9 @@ FileUtil::loadFile(const vespalib::string &fileName) void FileReaderBase::handleError(ssize_t numRead, size_t wanted) { if (numRead == 0) { - throw std::runtime_error(vespalib::make_string("Trying to read past EOF of file %s", _file.GetFileName())); + throw std::runtime_error(vespalib::make_string("Trying to read past EOF of file %s", _file->GetFileName())); } else { - throw std::runtime_error(vespalib::make_string("Partial read(%zd of %zu) of file %s", numRead, wanted, _file.GetFileName())); + throw std::runtime_error(vespalib::make_string("Partial read(%zd of %zu) of file %s", numRead, wanted, _file->GetFileName())); } } @@ -126,7 +126,7 @@ void FileWriterBase::handleError(ssize_t numRead, size_t wanted) ssize_t FileReaderBase::read(void *buf, size_t sz) { - ssize_t numRead = _file.Read(buf, sz); + ssize_t numRead = _file->Read(buf, sz); if (numRead != ssize_t(sz)) { handleError(numRead, sz); } diff --git a/searchlib/src/vespa/searchlib/util/fileutil.h b/searchlib/src/vespa/searchlib/util/fileutil.h index 8271265aa33..bb74aa47484 100644 --- a/searchlib/src/vespa/searchlib/util/fileutil.h +++ b/searchlib/src/vespa/searchlib/util/fileutil.h @@ -73,11 +73,11 @@ public: class FileReaderBase { public: - FileReaderBase(FastOS_FileInterface & file) : _file(file) { } + FileReaderBase(FastOS_FileInterface * file) : _file(file) { } ssize_t read(void *buf, size_t sz); private: void handleError(ssize_t numRead, size_t wanted); - FastOS_FileInterface & _file; + FastOS_FileInterface * _file; }; class FileWriterBase @@ -95,7 +95,7 @@ template <typename T> class FileReader : public FileReaderBase { public: - FileReader(FastOS_FileInterface & file) : FileReaderBase(file) { } + FileReader(FastOS_FileInterface * file) : FileReaderBase(file) { } T readHostOrder() { T result; read(&result, sizeof(result)); diff --git a/vespalib/src/vespa/vespalib/data/databuffer.cpp b/vespalib/src/vespa/vespalib/data/databuffer.cpp index 8640a369267..313fbe58fab 100644 --- a/vespalib/src/vespa/vespalib/data/databuffer.cpp +++ b/vespalib/src/vespa/vespalib/data/databuffer.cpp @@ -77,7 +77,9 @@ DataBuffer::shrink(size_t newsize) if (newsize != 0) { newbuf = static_cast<char *>(newBuf.get()); newdata = newbuf + padbefore(_alignment, newbuf); - memcpy(newdata, _datapt, getDataLen()); + if (getDataLen() > 0) { + memcpy(newdata, _datapt, getDataLen()); + } } _buffer.swap(newBuf); _bufstart = newbuf; @@ -101,7 +103,9 @@ DataBuffer::pack(size_t needbytes) Alloc newBuf(_buffer.create(bufsize)); char *newbuf = static_cast<char *>(newBuf.get()); char *newdata = newbuf + padbefore(_alignment, newbuf); - memcpy(newdata, _datapt, dataLen); + if (dataLen > 0) { + memcpy(newdata, _datapt, dataLen); + } _bufstart = newbuf; _datapt = newdata; _freept = newdata + dataLen; @@ -109,7 +113,9 @@ DataBuffer::pack(size_t needbytes) _buffer.swap(newBuf); } else { char *datapt = _bufstart + padbefore(_alignment, _bufstart); - memmove(datapt, _datapt, dataLen); + if (dataLen > 0) { + memmove(datapt, _datapt, dataLen); + } _datapt = datapt; _freept = _datapt + dataLen; } @@ -119,8 +125,12 @@ DataBuffer::pack(size_t needbytes) bool DataBuffer::equals(DataBuffer *other) { - if (getDataLen() != other->getDataLen()) + if (getDataLen() != other->getDataLen()) { return false; + } + if (getDataLen() == 0) { + return true; + } return memcmp(getData(), other->getData(), getDataLen()) == 0; } diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.cpp b/vespalib/src/vespa/vespalib/objects/nbostream.cpp index c4af25efcac..a369bd21c56 100644 --- a/vespalib/src/vespa/vespalib/objects/nbostream.cpp +++ b/vespalib/src/vespa/vespalib/objects/nbostream.cpp @@ -60,7 +60,9 @@ nbostream::nbostream(const nbostream & rhs) : { extend(rhs.size()); _wp = rhs.size(); - memcpy(_wbuf.data(), &rhs._rbuf[rhs._rp], _wp); + if (_wp > 0) { + memcpy(_wbuf.data(), &rhs._rbuf[rhs._rp], _wp); + } } nbostream::nbostream(nbostream && rhs) noexcept @@ -76,7 +78,9 @@ nbostream::nbostream(nbostream && rhs) noexcept rhs._rbuf = ConstBufferRef(); if (!_longLivedBuffer && (_wbuf.capacity() == 0)) { _wbuf.resize(roundUp2inN(_rbuf.size())); - memcpy(_wbuf.data(), &_rbuf[_rp], size()); + if (size() > 0) { + memcpy(_wbuf.data(), &_rbuf[_rp], size()); + } _wp = size(); _rp = 0; _rbuf = ConstBufferRef(_wbuf.data(), _wbuf.capacity()); @@ -120,7 +124,9 @@ void nbostream::reserve(size_t sz) void nbostream::compact() { - memmove(_wbuf.data(), &_rbuf[_rp], left()); + if (left() > 0) { + memmove(_wbuf.data(), &_rbuf[_rp], left()); + } _wp = left(); _rp = 0; } diff --git a/vespalib/src/vespa/vespalib/objects/nbostream.h b/vespalib/src/vespa/vespalib/objects/nbostream.h index e7bed8d59ff..12d4fac04cc 100644 --- a/vespalib/src/vespa/vespalib/objects/nbostream.h +++ b/vespalib/src/vespa/vespalib/objects/nbostream.h @@ -159,7 +159,9 @@ public: if (__builtin_expect(space() < sz, false)) { extend(sz); } - memcpy(&_wbuf[_wp], v, sz); + if (sz > 0) { + memcpy(&_wbuf[_wp], v, sz); + } _wp += sz; } void read(void *v, size_t sz) { |