fix potential memory leak in dynarray