[beast: 3/4] TOOLS: bsefextract: don't segfault if input file is empty
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 3/4] TOOLS: bsefextract: don't segfault if input file is empty
- Date: Mon, 13 Mar 2017 22:22:43 +0000 (UTC)
commit af844648baeebbf22228f8df812a108b035372d9
Author: Stefan Westerfeld <stefan space twc de>
Date: Sun Mar 12 21:22:24 2017 +0100
TOOLS: bsefextract: don't segfault if input file is empty
Signed-off-by: Stefan Westerfeld <stefan space twc de>
tools/bsefextract.cc | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/tools/bsefextract.cc b/tools/bsefextract.cc
index 2b4f90a..2251d49 100644
--- a/tools/bsefextract.cc
+++ b/tools/bsefextract.cc
@@ -77,6 +77,17 @@ class Signal
return true;
}
+ /* empty signal? */
+ bool empty()
+ {
+ if (m_length < m_n_channels)
+ {
+ assert (m_length == 0);
+ return true;
+ }
+ return false;
+ }
+
public:
Signal (GslDataHandle *data_handle) :
m_data_handle (data_handle)
@@ -102,7 +113,7 @@ public:
if (options.cut_zeros_head)
{
/* cut_zeros head */
- while (head_is_silent() && m_length > (GslLong) m_n_channels)
+ while (!empty() && head_is_silent())
{
m_offset += m_n_channels;
m_length -= m_n_channels;
@@ -111,7 +122,7 @@ public:
if (options.cut_zeros_tail)
{
/* cut_zeros tail */
- while (tail_is_silent() && m_length > (GslLong) m_n_channels)
+ while (!empty() && tail_is_silent())
{
m_length -= m_n_channels;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]