File 0008-Fix-type-punning-in-smplfile.c.patch of Package timidity

From fd07758bc2b608771a04216b6d862e6766def73d Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Wed, 30 May 2012 15:04:23 +0200
Subject: [PATCH 8/9] Fix type-punning in smplfile.c

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 timidity/smplfile.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/timidity/smplfile.c b/timidity/smplfile.c
index cab2727..e528596 100755
--- a/timidity/smplfile.c
+++ b/timidity/smplfile.c
@@ -316,7 +316,11 @@ static int import_wave_discriminant(char *sample_file)
 static int import_wave_load(char *sample_file, Instrument *inst)
 {
 	struct timidity_file	*tf;
-	char			buf[12];
+	union {
+		int32 i[3];
+		char c[12];
+	} xbuf;
+	char			*buf = xbuf.c;
 	int				state;		/* initial > fmt_read > data_read */
 	int				i, chunk_size, type_index, type_size, samples = 0;
 	int32			chunk_flags;
@@ -339,7 +343,7 @@ static int import_wave_load(char *sample_file, Instrument *inst)
 	for(;;) {
 		if (tf_read(&buf[type_index], type_size, 1, tf) != 1)
 			break;
-		chunk_size = LE_LONG(*(int32 *)&buf[4 + 4]);
+		chunk_size = LE_LONG(xbuf.i[2]);
 		if (memcmp(&buf[4 + 0], "fmt ", 4) == 0)
 		{
 			if (state != 0					/* only one format chunk is required */
@@ -598,7 +602,11 @@ static int import_aiff_discriminant(char *sample_file)
 static int import_aiff_load(char *sample_file, Instrument *inst)
 {
 	struct timidity_file	*tf;
-	char			buf[12];
+	union {
+		int32 i[3];
+		char c[12];
+	} xbuf;
+	char			*buf = xbuf.c;
 	int				chunk_size, type_index, type_size;
 	int				compressed;
 	int32			chunk_flags;
@@ -627,7 +635,7 @@ static int import_aiff_load(char *sample_file, Instrument *inst)
 	for(;;) {
 		if (tf_read(&buf[type_index], type_size, 1, tf) != 1)
 			break;
-		chunk_size = BE_LONG(*(int32 *)&buf[4 + 4]);
+		chunk_size = BE_LONG(xbuf.i[2]);
 		if (memcmp(&buf[4 + 0], "COMM", 4) == 0)
 		{
 			if (chunk_flags & AIFF_CHUNKFLAG_COMMON)
-- 
1.7.9.2

openSUSE Build Service is sponsored by