From 1e2bc11e996491ca1d3a44f5826ab29b312120c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 16 Oct 2008 19:48:28 +0000 Subject: [PATCH] bonefish+mmu_man: fix cbuf_user_memcpy_from_chain() returning an error when the source buffer was NULL despite being asked for 0 bytes, while the counterpart was actually not creating a buffer for 0 bytes to send... Also don't bother calling it from receive_data() in that case anyway. This fixes a deadlock in SoundPlay that made it freeze when trying to play the 2nd sound. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28179 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/thread.cpp | 2 +- src/system/kernel/util/cbuf.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/thread.cpp b/src/system/kernel/thread.cpp index 7e2706aa85..a28c39147b 100644 --- a/src/system/kernel/thread.cpp +++ b/src/system/kernel/thread.cpp @@ -743,7 +743,7 @@ receive_data_etc(thread_id *_sender, void *buffer, size_t bufferSize, return status; } - if (buffer != NULL && bufferSize != 0) { + if (buffer != NULL && bufferSize != 0 && thread->msg.buffer != NULL) { size = min_c(bufferSize, thread->msg.size); status = cbuf_user_memcpy_from_chain(buffer, thread->msg.buffer, 0, size); diff --git a/src/system/kernel/util/cbuf.c b/src/system/kernel/util/cbuf.c index 636da5b08c..133dc27605 100644 --- a/src/system/kernel/util/cbuf.c +++ b/src/system/kernel/util/cbuf.c @@ -529,6 +529,8 @@ cbuf_user_memcpy_from_chain(void *_dest, cbuf *chain, size_t offset, size_t leng int bufferOffset; int err; + if (length == 0) + return B_OK; if (chain == NULL) return B_BAD_VALUE;