From 87e1afd4be4b7ff608d0d799597cc13df2bcdc43 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 20 Mar 2017 02:42:29 +0100 Subject: Fix value buffer size logic --- src/server/Buffer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp index 2f26eafb..7af3d47e 100644 --- a/src/server/Buffer.cpp +++ b/src/server/Buffer.cpp @@ -406,11 +406,12 @@ Buffer::set_value(const Atom& value) return; } - if (value.size() > _value_buffer->size()) { - _value_buffer = _factory.claim_buffer(value.type(), 0, value.size()); + const uint32_t total_size = sizeof(LV2_Atom) + value.size(); + if (total_size > _value_buffer->capacity()) { + _value_buffer = _factory.claim_buffer(value.type(), 0, total_size); } - memcpy(_value_buffer->get(), value.atom(), sizeof(LV2_Atom) + value.size()); + memcpy(_value_buffer->get(), value.atom(), total_size); } void -- cgit v1.2.1