Commit de1807bb authored by Josh Allmann's avatar Josh Allmann Committed by Martin Storsjö

Pad the buffer in url_close_dyn_buf, for buffers opened with url_open_dyn_buf

Patch by Josh Allmann, joshua dot allmann at gmail

Originally committed as revision 23942 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 4449df6b
...@@ -530,7 +530,10 @@ int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size); ...@@ -530,7 +530,10 @@ int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
/** /**
* Return the written size and a pointer to the buffer. The buffer * Return the written size and a pointer to the buffer. The buffer
* must be freed with av_free(). * must be freed with av_free(). If the buffer is opened with
* url_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is
* added; if opened with url_open_dyn_packet_buf, no padding is added.
*
* @param s IO context * @param s IO context
* @param pbuffer pointer to a byte buffer * @param pbuffer pointer to a byte buffer
* @return the length of the byte buffer * @return the length of the byte buffer
......
...@@ -894,6 +894,14 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) ...@@ -894,6 +894,14 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
{ {
DynBuffer *d = s->opaque; DynBuffer *d = s->opaque;
int size; int size;
static const char padbuf[FF_INPUT_BUFFER_PADDING_SIZE] = {0};
int padding = 0;
/* don't attempt to pad fixed-size packet buffers */
if (!s->max_packet_size) {
put_buffer(s, padbuf, sizeof(padbuf));
padding = FF_INPUT_BUFFER_PADDING_SIZE;
}
put_flush_packet(s); put_flush_packet(s);
...@@ -901,6 +909,6 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer) ...@@ -901,6 +909,6 @@ int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer)
size = d->size; size = d->size;
av_free(d); av_free(d);
av_free(s); av_free(s);
return size; return size - padding;
} }
#endif /* CONFIG_MUXERS || CONFIG_NETWORK */ #endif /* CONFIG_MUXERS || CONFIG_NETWORK */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment