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>