av: Fix compile errors
Don't use memcpy() on areas that may overlap
Fix aliasing violation
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
diff --git a/media/libeffects/downmix/EffectDownmix.c b/media/libeffects/downmix/EffectDownmix.c
index 1048ccd..a860152 100644
--- a/media/libeffects/downmix/EffectDownmix.c
+++ b/media/libeffects/downmix/EffectDownmix.c
@@ -632,7 +632,7 @@
return -EINVAL;
}
- memcpy(&pDwmModule->config, pConfig, sizeof(effect_config_t));
+ memmove(&pDwmModule->config, pConfig, sizeof(effect_config_t));
if (init) {
pDownmixer->type = DOWNMIX_TYPE_FOLD;
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
index 90aed39..5419cf0 100644
--- a/media/libmediaplayerservice/MediaPlayerFactory.cpp
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -175,12 +175,15 @@
int64_t offset,
int64_t length,
float curScore) {
- char buf[20];
+ union {
+ char buf[20];
+ long bufl[20/sizeof(long)];
+ };
lseek(fd, offset, SEEK_SET);
read(fd, buf, sizeof(buf));
lseek(fd, offset, SEEK_SET);
- long ident = *((long*)buf);
+ const long ident = bufl[0];
// Ogg vorbis?
if (ident == 0x5367674f) // 'OggS'