diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-05-05 00:50:29 +0200 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-05-05 00:50:29 +0200 |
commit | 92008cafc160f3bcf7aaaea52a9ec38a589ec8ce (patch) | |
tree | 4ad8c1a633fbc020b803a0b2c4491dcd0e9e75ce | |
parent | d20941a05101fb6b3d8be5e9392ecc1f7dbea900 (diff) | |
download | base-92008cafc160f3bcf7aaaea52a9ec38a589ec8ce.tar.gz |
voip: Fix aliasing violation
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | voip/jni/rtp/AudioGroup.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/voip/jni/rtp/AudioGroup.cpp b/voip/jni/rtp/AudioGroup.cpp index 459756dbe17a..b3a672932ef6 100644 --- a/voip/jni/rtp/AudioGroup.cpp +++ b/voip/jni/rtp/AudioGroup.cpp @@ -406,7 +406,11 @@ void AudioStream::decode(int tick) count = recv(mSocket, samples, sizeof(samples), MSG_TRUNC | MSG_DONTWAIT) >> 1; } else { - __attribute__((aligned(4))) uint8_t buffer[2048]; + __attribute__((aligned(4))) union { + uint8_t buffer[2048]; + uint16_t buffer16[2048/2]; + uint32_t buffer32[2048/4]; + }; sockaddr_storage remote; socklen_t addrlen = sizeof(remote); @@ -416,13 +420,13 @@ void AudioStream::decode(int tick) // Do we need to check SSRC, sequence, and timestamp? They are not // reliable but at least they can be used to identify duplicates? if (length < 12 || length > (int)sizeof(buffer) || - (ntohl(*(uint32_t *)buffer) & 0xC07F0000) != mCodecMagic) { + (ntohl(*buffer32) & 0xC07F0000) != mCodecMagic) { LOGV("stream[%d] malformed packet", mSocket); return; } int offset = 12 + ((buffer[0] & 0x0F) << 2); if ((buffer[0] & 0x10) != 0) { - offset += 4 + (ntohs(*(uint16_t *)&buffer[offset + 2]) << 2); + offset += 4 + (ntohs(buffer16[(offset + 2)/2]) << 2); } if ((buffer[0] & 0x20) != 0) { length -= buffer[length - 1]; |