1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
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 | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/hcom.c b/src/hcom.c
index 75a2820..84643a2 100644
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -446,13 +446,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" */
|