diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 19:53:34 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 19:53:34 +0200 |
commit | d9879fae94a82bb6b43af44102613dcf7db01f30 (patch) | |
tree | 00b17dbdbae2e6878f5fd4c66d9e6a0b9cd16b89 | |
parent | 795202860a4113f540a6a8728e272166d41158a4 (diff) | |
download | xine-lib-d9879fae94a82bb6b43af44102613dcf7db01f30.tar.gz xine-lib-d9879fae94a82bb6b43af44102613dcf7db01f30.tar.bz2 |
Don't use t_title array after it got out of the scope.
In update_chapter_display() the t_title array, declared on the buffer,
is used after it has disappeared from the scope. Instead of doing
that, use directly the xine_ui_data_t array.
Declare xine_event_t and xine_ui_data_t with their values directly,
makes it more explicit that everything disappears at the end of the
function.
--HG--
extra : transplant_source : %25T%10eEd%CF%ECS%AC%A3%E3%E0%D3J%F6%A5%15%9EE
-rw-r--r-- | src/demuxers/demux_ogg.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index e0cddfcf4..a58304744 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -304,10 +304,10 @@ static void send_ogg_packet (demux_ogg_t *this, buf_element_t *buf; int done=0,todo=op->bytes; - int op_size = sizeof(ogg_packet); + const size_t op_size = sizeof(ogg_packet); while (done<todo) { - int offset=0; + size_t offset=0; buf = fifo->buffer_pool_alloc (fifo); buf->decoder_flags = decoder_flags; if (done==0) { @@ -531,34 +531,34 @@ static void update_chapter_display (demux_ogg_t *this, int stream_num, ogg_packe chapter--; if (chapter != this->chapter_info->current_chapter){ - xine_event_t uevent; - xine_ui_data_t data; - int title_len; - char *title; + xine_ui_data_t data = { + .str = { 0, }, + .str_len = 0 + }; + xine_event_t uevent = { + .type = XINE_EVENT_UI_SET_TITLE, + .stream = this->stream, + .data = &data, + .data_length = sizeof(data) + }; this->chapter_info->current_chapter = chapter; - if (chapter >= 0) { - char t_title[256]; + if (chapter >= 0) { if (this->title) { - snprintf(t_title, sizeof (t_title), "%s / %s", this->title, this->chapter_info->entries[chapter].name); + data.str_len = snprintf(data.str, sizeof(data.str), "%s / %s", this->title, this->chapter_info->entries[chapter].name); } else { - snprintf(t_title, sizeof (t_title), "%s", this->chapter_info->entries[chapter].name); + strncpy(data.str, this->chapter_info->entries[chapter].name, sizeof(data.str)-1); } - title = t_title; } else { - title = this->title; + strncpy(data.str, this->title, sizeof(data.str)); } - _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, title); - lprintf("new TITLE: %s\n", title); - - uevent.type = XINE_EVENT_UI_SET_TITLE; - uevent.stream = this->stream; - uevent.data = &data; - uevent.data_length = sizeof(data); - title_len = strlen(title) + 1; - memcpy(data.str, title, title_len); - data.str_len = title_len; + if ( data.str_len == 0 ) + data.str_len = strlen(data.str); + + _x_meta_info_set(this->stream, XINE_META_INFO_TITLE, data.str); + lprintf("new TITLE: %s\n", data.str); + xine_event_send(this->stream, &uevent); } } |