Fix crash when buffer was reallocated after read_length_callback

Added test for this crash.