From david.henningsson@canonical.com  Mon Oct  1 15:06:56 2012
Return-Path: <david.henningsson@canonical.com>
X-Original-To: diwic@mail.canonical.com
Delivered-To: diwic@mail.canonical.com
Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145])
	by grenadilla.canonical.com (Postfix) with ESMTP id A48961472160
	for <diwic@mail.canonical.com>; Mon,  1 Oct 2012 15:06:56 +0000 (UTC)
Received: from cluster-e.mailcontrol.com (cluster-e.mailcontrol.com [85.115.58.190])
	by fiordland.canonical.com (Postfix) with ESMTP id 5DC1EA18423
	for <david.henningsson@cleanmail.canonical.com>; Mon,  1 Oct 2012 15:06:56 +0000 (UTC)
Received: from arctowski.canonical.com (arctowski.canonical.com [91.189.94.158])
	by rly62e.srv.mailcontrol.com (MailControl) with ESMTP id q91F6t9E016745
	for <david.henningsson@cleanmail.canonical.com>; Mon, 1 Oct 2012 16:06:55 +0100
Received: from fiordland.canonical.com ([91.189.94.145])
	by arctowski.canonical.com with esmtp (Exim 4.71)
	(envelope-from <david.henningsson@canonical.com>)
	id 1TIhaB-0002MW-HX
	for david.henningsson@cleanmail.canonical.com; Mon, 01 Oct 2012 15:06:55 +0000
Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112])
	by fiordland.canonical.com (Postfix) with ESMTP id 8706DA18423
	for <david.henningsson@canonical.com>; Mon,  1 Oct 2012 15:06:55 +0000 (UTC)
Received: from hd9483857.selulk5.dyn.perspektivbredband.net ([217.72.56.87] helo=localhost.localdomain)
	by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71)
	(envelope-from <david.henningsson@canonical.com>)
	id 1TIhaB-0006f2-8F; Mon, 01 Oct 2012 15:06:55 +0000
From: David Henningsson <david.henningsson@canonical.com>
To: pulseaudio-discuss@lists.freedesktop.org
Cc: 1058200@bugs.launchpad.net,
        David Henningsson <david.henningsson@canonical.com>
Subject: [PATCH] stream: Return error in case a client peeks to early
Date: Mon,  1 Oct 2012 17:06:55 +0200
Message-Id: <1349104015-5924-1-git-send-email-david.henningsson@canonical.com>
X-Mailer: git-send-email 1.7.9.5
X-Mailcontrol-Inbound: uq3drnD2P+ps5SfEb0fvr78+NoP1DHBZwGqKpaXB2eTgNv8D6KLIxb8+NoP1DHBZ8VSaBg0k0xw=
X-Spam-Score: -0.4
X-Scanned-By: MailControl 9446.0 (www.mailcontrol.com) on 10.69.0.172

If there is no silence memblock and no data, pa_memblockq_peek can
return NULL. In this case, do not crash on an assertion in
pa_memblock_acquire, but instead return a proper error to the client.

BugLink: http://bugs.launchpad.net/bugs/1058200
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
---
 src/pulse/stream.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 2b6d306..9bb0995 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -1598,6 +1598,8 @@ int pa_stream_peek(pa_stream *s, const void **data, size_t *length) {
             return 0;
         }
 
+        PA_CHECK_VALIDITY(s->context, s->peek_memchunk.memblock != NULL, PA_ERR_NODATA);
+
         s->peek_data = pa_memblock_acquire(s->peek_memchunk.memblock);
     }
 
-- 
1.7.9.5

