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;
}
|