Fixed #1069: serialize_buffer with allocator fails at destruction. Adding test.