[PATCH] bsefextract: don't segfault if input file is empty

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] bsefextract: don't segfault if input file is empty

Stefan Westerfeld
Here is a fix for:

> During testing I created an empty WAV file. Nothing worth listening to, but
> sweep loads it ok while bsefextract segfaults:
>...

Stefan Westerfeld (1):
  TOOLS: bsefextract: don't segfault if input file is empty

 tools/bsefextract.cc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

--
2.7.4

_______________________________________________
beast mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/beast
Reply | Threaded
Open this post in threaded view
|

[PATCH] TOOLS: bsefextract: don't segfault if input file is empty

Stefan Westerfeld
Signed-off-by: Stefan Westerfeld <[hidden email]>
---
 tools/bsefextract.cc | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/bsefextract.cc b/tools/bsefextract.cc
index 501698b..08cf18d 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;
   }
--
2.7.4

_______________________________________________
beast mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/beast