diff options
Diffstat (limited to 'src/input/input_rtp.c')
-rw-r--r-- | src/input/input_rtp.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index 25498f289..90bae6670 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -453,6 +453,9 @@ static off_t rtp_plugin_read (input_plugin_t *this_gen, struct timespec timeout; off_t copied = 0; + if (length < 0) + return -1; + while(length > 0) { off_t n; @@ -524,6 +527,12 @@ static buf_element_t *rtp_plugin_read_block (input_plugin_t *this_gen, buf_element_t *buf = fifo->buffer_pool_alloc (fifo); int total_bytes; + if (todo > buf->max_size) + todo = buf->max_size; + if (todo < 0) { + buf->free_buffer (buf); + return NULL; + } buf->content = buf->mem; buf->type = BUF_DEMUX_BLOCK; @@ -609,11 +618,14 @@ static int rtp_plugin_get_optional_data (input_plugin_t *this_gen, if (data_type == INPUT_OPTIONAL_DATA_PREVIEW) { if (!this->preview_read_done) { this->preview_size = rtp_plugin_read(this_gen, this->preview, MAX_PREVIEW_SIZE); + if (this->preview_size < 0) + this->preview_size = 0; lprintf("Preview data length = %d\n", this->preview_size); this->preview_read_done = 1; } - memcpy(data, this->preview, this->preview_size); + if (this->preview_size) + memcpy(data, this->preview, this->preview_size); return this->preview_size; } else { @@ -717,7 +729,7 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, } } - this = (rtp_input_plugin_t *) xine_xmalloc(sizeof(rtp_input_plugin_t)); + this = calloc(1, sizeof(rtp_input_plugin_t)); this->stream = stream; this->mrl = mrl; this->filename = filename; @@ -784,7 +796,7 @@ static void *init_class (xine_t *xine, void *data) { rtp_input_class_t *this; - this = (rtp_input_class_t *) xine_xmalloc(sizeof(rtp_input_class_t)); + this = calloc(1, sizeof(rtp_input_class_t)); this->config = xine->config; this->xine = xine; |