a=b;
After this assignment a points to the same location as b (“Secure Coding”). You have lost any reference to the initial location pointed by a, so essentially “Insecure Coding” is garbage that cannot be freed.
Another issue is that you are freeing the same pointer twice. After the first free you no longer own that memory.
See: What happens when you try to free() already freed memory in c?
solved C++ vulnerability issue with pointers