Fix misuse of sizeof on dynamic allocation