av: Fix compile errors

Don't use memcpy() on areas that may overlap
Fix aliasing violation