Https://ffmpeg.org/pipermail/libav-user/2012-December/003257.html
I get a double free or corruption problem, should really do a bugreport but don ' T have time to decipher the ffmpeg bug reporting page. I ' Ll post it here in case anyone is interested, feel free to ignore. when using custom io for reading involves something like thefollowing when creating a context:buffer = (uint8_t*) Av_malloc ( BUFFER_ size ); Ctxt = avio_alloc_context ( buffer, buffer_size, 0, this,read_ function, null, null ); And then to free it:av_free ( ctxt ); av_ Free ( buffer ); However, if buffer_size > 32768 bytes then av_free ( buffer ) resultsin a crash due to invalid free/delete (Which can also be detected byvalgrind). Not calling av_free ( buffer ) leads to a memory leak ( Reported by valgrind). In the case of calling av_free () valgrind reports the buffer asalready being free ' d in:==5471== address 0x9181680 is 0 Bytes inside a block of size 32,784 free ' d==5471== at 0x4c2a82e: free (in/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5471== by 0x712EC6F: av_free (mem.c:186) ==5471==    BY 0X6DBEFC4: ffio_set_buf_size (aviobuf.c:707) ==5471== by 0x6dbe1e5: fill_ buffer (aviobuf.c:408) ==5471== by 0x6dbe570: avio_read (AVIOBUF.C : 495) ==5471== by 0x6de8971: ff_id3v2_read (id3v2.c:748) ==5471== by 0x6EA4F42: avformat_open_input (utils.c:638) which if you follow the call in a debugger leads to the culprit ataviobuf.c:408: /* make buffer smaller in case it ended up large after probing */ if (s->read_packet && s-> Buffer_size > max_buffer_size) { ffio_set_buf _size (s, max_buffer_size); s->checksum_ptr = Dst = s->buffer; len = s->buffer_size ; }this only gets called when we are reading. So in the case of usingcustom input libav takes it upon itself to Tinker with the usersupplied buffer. the crash only occurs if the buffer size is largerthan 32KBwhich in my case it was because i was trying to follow some exampleswhich show allocating (32768 + ff_input_buffer_padding_size) bytes. I don ' T know if the bug is that libav is supposed to give an error ifthe buffer is larger than 32kb, or not tinker with user suppliedbuffers, or avio_alloc_context should take a ** to the buffer so itcan reallocate properly and Clients don ' T HAVETO CHOOSE BETWEEN&Nbsp;a double free or a memory leak, but its definitelywrong One way or another. i actually do not understand why the userneeds to pass in the buffer at all as it seems avio_alloc_contextcould do it internally if it is going Toreallocate it on a whim anyway.regards,mark
As you can see from this description, when using custom input, if Iobuffer is greater than 32KB, it causes a segment error at Av_free (Iobuffer). This is a very strange question.
Ffmpeg:av_free Segment Error