From 18d2609a2362a43928d45bbd806b17ebd7fa8eb8 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Sat, 28 Apr 2018 18:53:46 +0100
Subject: [PATCH] hcom: fix pointer type confusion [bug #308]

The compress() call fails on big endian systems with size_t bigger
than int32_t.  Fix by using the correct types.
---
 src/hcom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

From 998208fd1c18fcbbf2a5bcabdbcec72649cfc387 Mon Sep 17 00:00:00 2001
From: Mans Rullgard <mans@mansr.com>
Date: Thu, 27 Aug 2015 16:57:26 +0100
Subject: [PATCH] hcom: fix double free on writing zero-length file

---
 src/hcom.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/hcom.c b/src/hcom.c
index f7c88d07..00653ed9 100644
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -441,13 +441,14 @@ static int stopwrite(sox_format_t * ft)
 {
   priv_t *p = (priv_t *) ft->priv;
   unsigned char *compressed_data = p->data;
-  size_t compressed_len = p->pos;
+  int32_t compressed_len = p->pos;
   int rc = SOX_SUCCESS;
 
   /* Compress it all at once */
-  if (compressed_len)
-    compress(ft, &compressed_data, (int32_t *)&compressed_len);
-  free(p->data);
+  if (compressed_len) {
+    compress(ft, &compressed_data, &compressed_len);
+    free(p->data);
+  }
 
   /* Write the header */
   lsx_writebuf(ft, "\000\001A", (size_t) 3); /* Dummy file name "A" */
-- 
2.39.1

