From 9cda41d51a50a319676d24ba85dc5f39747ba356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 13 Dec 2007 17:31:53 +0100 Subject: Free the temporary variables that are allocated, avoid memory leaks. (transplanted from c994a2508893efc4c85f5b49600b7dceec5c890e) --HG-- extra : transplant_source : %C9%94%A2P%88%93%EF%C4%C8_%5BI%60%0B%7D%CE%EC%5C%89%0E --- src/demuxers/demux_matroska.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c index 0169651a0..4f3476049 100644 --- a/src/demuxers/demux_matroska.c +++ b/src/demuxers/demux_matroska.c @@ -1181,8 +1181,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { case MATROSKA_ID_TR_CODECID: { char *codec_id = malloc (elem.len + 1); lprintf("CodecID\n"); - if (!ebml_read_ascii(ebml, &elem, codec_id)) + if (!ebml_read_ascii(ebml, &elem, codec_id)) { + free(codec_id); return 0; + } codec_id[elem.len] = '\0'; track->codec_id = codec_id; } @@ -1191,8 +1193,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { case MATROSKA_ID_TR_CODECPRIVATE: { char *codec_private = malloc (elem.len); lprintf("CodecPrivate\n"); - if (!ebml_read_binary(ebml, &elem, codec_private)) + if (!ebml_read_binary(ebml, &elem, codec_private)) { + free(codec_private); return 0; + } track->codec_private = codec_private; track->codec_private_len = elem.len; } @@ -1201,8 +1205,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) { case MATROSKA_ID_TR_LANGUAGE: { char *language = malloc (elem.len + 1); lprintf("Language\n"); - if (!ebml_read_ascii(ebml, &elem, language)) + if (!ebml_read_ascii(ebml, &elem, language)) { + free(language); return 0; + } language[elem.len] = '\0'; track->language = language; } -- cgit v1.2.3 From 04b9c745d4e4c379724df14a422e35ad81c7bce6 Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 14 Dec 2007 20:00:52 +0100 Subject: Fixed a crash that happened when a video output was closed img->stream->video_fifo can be 0 --- ChangeLog | 1 + src/xine-engine/video_out.c | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index c89b74b3d..5212cf99b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,7 @@ xine-lib (1.1.9) (unreleased) * DXR3 encoding with external ffmpeg should be fixed now. (This was broken by ffmpeg revision 9283). * Enabled the WMV VC1 (ffmpeg) codec. + * Fixed a crash that happened when a video output was closed xine-lib (1.1.8) * Send a channel-changed event to the frontend when receiving the SYNC diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index b961c6060..a5fd544d0 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -950,6 +950,7 @@ static vo_frame_t *get_next_frame (vos_t *this, int64_t cur_vpts, if (!img->stream || _x_stream_info_get(img->stream, XINE_STREAM_INFO_VIDEO_HAS_STILL) || + !img->stream->video_fifo || img->stream->video_fifo->size(img->stream->video_fifo) < 10) { lprintf ("possible still frame\n"); -- cgit v1.2.3 From 64a216c54142bde7188b690776c0a5decc0cef94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 13 Dec 2007 19:29:35 +0100 Subject: If the number of channels is not in the known cases, return a failure. (transplanted from f3d84191da5d930ac90193bbdc0ca5d7c43b8302) --HG-- extra : transplant_source : D%837c_%7D%89%F0%E3%2B%7C%96%85IM9%250D%ED --- src/libfaad/xine_faad_decoder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libfaad/xine_faad_decoder.c b/src/libfaad/xine_faad_decoder.c index 11a5c5798..934140a32 100644 --- a/src/libfaad/xine_faad_decoder.c +++ b/src/libfaad/xine_faad_decoder.c @@ -194,6 +194,8 @@ static int faad_open_output( faad_decoder_t *this ) { case 2: this->ao_cap_mode=AO_CAP_MODE_STEREO; break; + default: + return 0; } this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, -- cgit v1.2.3 From d1d18588d3bc91f72f6e9534d1f90b8aac7c118f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Thu, 13 Dec 2007 19:38:53 +0100 Subject: Set stream information only when reading a streaminfo FLAC block. (transplanted from 6d9f36be48839984c3888f3d803319942c4d76e6) --HG-- extra : transplant_source : E%81r%E5-%5B%C2%21%15h%E3_%CB%23%25%9B%01l%03Y --- src/demuxers/demux_ogg.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c index 4eacf7070..9ed39f12d 100644 --- a/src/demuxers/demux_ogg.c +++ b/src/demuxers/demux_ogg.c @@ -1221,16 +1221,17 @@ static void decode_flac_header (demux_ogg_t *this, const int stream_num, ogg_pac case FLAC_BLOCKTYPE_STREAMINFO: _x_assert(header.length == FLAC_STREAMINFO_SIZE); _x_parse_flac_streaminfo_block(&op->packet[17], &streaminfo); + + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, streaminfo.samplerate); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, streaminfo.channels); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, streaminfo.bits_per_sample); + break; } this->si[stream_num]->buf_types = BUF_AUDIO_FLAC +this->num_audio_streams++; - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, streaminfo.samplerate); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_CHANNELS, streaminfo.channels); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITS, streaminfo.bits_per_sample); - this->si[stream_num]->factor = 90000; buf = this->audio_fifo->buffer_pool_alloc(this->audio_fifo); -- cgit v1.2.3 From 6bbfd480d0d173887305db527b641f832b6c4310 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 14 Dec 2007 21:44:43 +0000 Subject: Convert XML to UTF-8 for parsing if a BOM is detected. --- ChangeLog | 1 + src/xine-utils/xmllexer.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5212cf99b..2102e3db5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ xine-lib (1.1.9) (unreleased) * Build fix for when using Linux 2.6.23 headers. [Bug 1820958] * Implemented decoding of XML character entities with codes >= 256. This requires conversion to UTF-8 of entities with codes >= 128. + * Handle initial Unicde BOMs in XML; convert other UTF encodings to UTF-8. * Fixed ATSC support. [Bug 1749508] * Fixed a possible DVB plugin crash when switching channels. * Fixed a crash closing the frontend. [Bug FS#3] diff --git a/src/xine-utils/xmllexer.c b/src/xine-utils/xmllexer.c index 8879f7d0c..75362e10d 100644 --- a/src/xine-utils/xmllexer.c +++ b/src/xine-utils/xmllexer.c @@ -40,6 +40,8 @@ #include #endif +#include "bswap.h" + /* private constants*/ #define NORMAL 0 /* normal lex mode */ #define DATA 1 /* data lex mode */ @@ -50,10 +52,70 @@ static int lexbuf_size = 0; static int lexbuf_pos = 0; static int lex_mode = NORMAL; static int in_comment = 0; +static char *lex_malloc = NULL; + +enum utf { UTF32BE, UTF32LE, UTF16BE, UTF16LE }; + +static void lex_convert (const char * buf, int size, enum utf utf) +{ + char *utf8 = malloc (size * (utf >= UTF16BE ? 3 : 6) + 1); + char *bp = utf8; + while (size > 0) + { + uint32_t c = 0; + switch (utf) + { + case UTF32BE: c = _X_BE_32 (buf); buf += 4; break; + case UTF32LE: c = _X_LE_32 (buf); buf += 4; break; + case UTF16BE: c = _X_BE_16 (buf); buf += 2; break; + case UTF16LE: c = _X_LE_16 (buf); buf += 2; break; + } + if (!c) + break; /* embed a NUL, get a truncated string */ + if (c < 128) + *bp++ = c; + else + { + int count = (c >= 0x04000000) ? 5 : + (c >= 0x00200000) ? 4 : + (c >= 0x00010000) ? 3 : + (c >= 0x00000800) ? 2 : 1; + *bp = (char)(0x1F80 >> count); + count *= 6; + *bp++ |= c >> count; + while ((count -= 6) >= 0) + *bp++ = 128 | ((c >> count) & 0x3F); + } + } + *bp = 0; + lexbuf_size = bp - utf8; + lexbuf = lex_malloc = realloc (utf8, lexbuf_size + 1); +} void lexer_init(const char * buf, int size) { + static const char boms[] = { 0xFF, 0xFE, 0, 0, 0xFE, 0xFF }, + bom_utf8[] = { 0xEF, 0xBB, 0xBF }; + + free (lex_malloc); + lex_malloc = NULL; + lexbuf = buf; lexbuf_size = size; + + if (size >= 4 && !memcmp (buf, boms + 2, 4)) + lex_convert (buf + 4, size - 4, UTF32BE); + else if (size >= 4 && !memcmp (buf, boms, 4)) + lex_convert (buf + 4, size - 4, UTF32LE); + else if (size >= 3 && !memcmp (buf, bom_utf8, 4)) + { + lexbuf += 3; + lexbuf_size -= 3; + } + else if (size >= 2 && !memcmp (buf, boms + 4, 2)) + lex_convert (buf + 2, size - 2, UTF16BE); + else if (size >= 2 && !memcmp (buf, boms, 2)) + lex_convert (buf + 2, size - 2, UTF16LE); + lexbuf_pos = 0; lex_mode = NORMAL; in_comment = 0; -- cgit v1.2.3