diff options
author | Timo Wischer <twischer@de.adit-jv.com> | 2020-03-26 09:24:52 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-04-05 13:58:21 +0200 |
commit | f831a1ebde048b4a19b380ff3794180152757efa (patch) | |
tree | 2215f55d81f886cbe8709d1c426cf8ab31a27612 /src | |
parent | 411f0e67f495fb436ce13ba12c63d7cf874aabd7 (diff) | |
download | jalv-f831a1ebde048b4a19b380ff3794180152757efa.tar.gz jalv-f831a1ebde048b4a19b380ff3794180152757efa.tar.bz2 jalv-f831a1ebde048b4a19b380ff3794180152757efa.zip |
worker: Only add response when enough space
for the complete response.
Without this patch the size of the response might be added but not the
response itself. This would corrupt the response queue because the
previously added size will be used for the next response which will be
added.
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/worker.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/worker.c b/src/worker.c index 1144120..8cb09d1 100644 --- a/src/worker.c +++ b/src/worker.c @@ -22,6 +22,10 @@ jalv_worker_respond(LV2_Worker_Respond_Handle handle, const void* data) { JalvWorker* worker = (JalvWorker*)handle; + if (zix_ring_write_space(worker->responses) < (sizeof(size) + size)) { + return LV2_WORKER_ERR_NO_SPACE; + } + zix_ring_write(worker->responses, (const char*)&size, sizeof(size)); zix_ring_write(worker->responses, (const char*)data, size); return LV2_WORKER_SUCCESS; |