shared: memset realloc'd memory to 0

To avoid having data in the union that wasn't set make sure to memset
the rest of a buffer after increasing the buffer's size. Size to
memset should be equal to the size requested minus the current offset
so that if we are at the 4th byte (offset=3) of a buffer size 5 we
will need to memset 2 bytes (5 - 3 = 2).