diff options
author | Dave Chapman <dave@dchapman.com> | 2006-01-29 01:31:28 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2006-01-29 01:31:28 +0000 |
commit | b0302f0cbb4674d9ff1584b87628f2bfaafa7a0a (patch) | |
tree | 9d6cf90f1380c244736f3a82665a7a9f56cfcd04 /apps | |
parent | 281403a4d839924df41480fc020f401211a6e88b (diff) | |
download | rockbox-b0302f0cbb4674d9ff1584b87628f2bfaafa7a0a.tar.gz rockbox-b0302f0cbb4674d9ff1584b87628f2bfaafa7a0a.zip |
Prevent unaligned memory accesses whilst reading seektable - fixes FLAC playback on iPod
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8477 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/codecs/flac.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index 4782c95d55..fa263c1095 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c | |||
@@ -86,7 +86,6 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) | |||
86 | int endofmetadata=0; | 86 | int endofmetadata=0; |
87 | int blocklength; | 87 | int blocklength; |
88 | int n; | 88 | int n; |
89 | uint32_t* p; | ||
90 | 89 | ||
91 | ci->memset(fc,0,sizeof(FLACContext)); | 90 | ci->memset(fc,0,sizeof(FLACContext)); |
92 | nseekpoints=0; | 91 | nseekpoints=0; |
@@ -152,12 +151,19 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) | |||
152 | if (n < 18) return false; | 151 | if (n < 18) return false; |
153 | blocklength-=n; | 152 | blocklength-=n; |
154 | 153 | ||
155 | p=(uint32_t*)buf; | 154 | seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) | |
156 | seekpoint_hi=betoh32(*(p++)); | 155 | (buf[2] << 8) | buf[3]; |
157 | seekpoint_lo=betoh32(*(p++)); | 156 | seekpoint_lo=(buf[4] << 24) | (buf[5] << 16) | |
158 | offset_hi=betoh32(*(p++)); | 157 | (buf[6] << 8) | buf[7]; |
159 | offset_lo=betoh32(*(p++)); | 158 | offset_hi=(buf[8] << 24) | (buf[9] << 16) | |
160 | 159 | (buf[10] << 8) | buf[11]; | |
160 | offset_lo=(buf[12] << 24) | (buf[13] << 16) | | ||
161 | (buf[14] << 8) | buf[15]; | ||
162 | |||
163 | /* The final two bytes contain the number of samples in the | ||
164 | target frame - but we don't care about that. */ | ||
165 | |||
166 | /* Only store seekpoints where the high 32 bits are zero */ | ||
161 | if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) && | 167 | if ((seekpoint_hi == 0) && (seekpoint_lo != 0xffffffff) && |
162 | (offset_hi == 0)) { | 168 | (offset_hi == 0)) { |
163 | seekpoints[nseekpoints].sample=seekpoint_lo; | 169 | seekpoints[nseekpoints].sample=seekpoint_lo; |