File: big-endian

package info (click to toggle)
espeak-ng 1.51%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 43,052 kB
  • sloc: ansic: 44,200; java: 4,059; xml: 1,684; python: 1,147; makefile: 1,032; sh: 864; cpp: 746; javascript: 682; php: 9
file content (46 lines) | stat: -rw-r--r-- 1,424 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
commit 2c524ec8df6b7f57c1ba1367479830bf9f6be6c2
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Fri Apr 8 01:18:16 2022 +0200

    Fix loading wav files on big-endian architectures
    
    Fixes #1152

---
 src/libespeak-ng/soundicon.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

--- a/src/libespeak-ng/soundicon.c
+++ b/src/libespeak-ng/soundicon.c
@@ -48,8 +48,7 @@ SOUND_ICON soundicon_tab[N_SOUNDICON_TAB
 static espeak_ng_STATUS LoadSoundFile(const char *fname, int index, espeak_ng_ERROR_CONTEXT *context)
 {
 	FILE *f;
-	char *p;
-	int *ip;
+	unsigned char *p;
 	int length;
 	char fname_temp[100];
 	char fname2[sizeof(path_home)+13+40];
@@ -121,7 +120,7 @@ static espeak_ng_STATUS LoadSoundFile(co
 		fclose(f);
 		return create_file_error_context(context, error, fname);
 	}
-	if ((p = (char *)realloc(soundicon_tab[index].data, length)) == NULL) {
+	if ((p = realloc(soundicon_tab[index].data, length)) == NULL) {
 		fclose(f);
 		return ENOMEM;
 	}
@@ -137,9 +136,9 @@ static espeak_ng_STATUS LoadSoundFile(co
 	if (fname_temp[0])
 		remove(fname_temp);
 
-	ip = (int *)(&p[40]);
-	soundicon_tab[index].length = (*ip) / 2; // length in samples
-	soundicon_tab[index].data = p;
+	length = p[40] | (p[41] << 8) | (p[42] << 16) | (p[43] << 24);
+	soundicon_tab[index].length = length / 2; // length in samples
+	soundicon_tab[index].data = (char *) p;
 	return ENS_OK;
 }