Mercurial > audlegacy-plugins
changeset 3053:a3734dd60d7a
Change the flow of codec probing to avoid the possibility of a null pointer dereference. From code analysis, unique IDs mPqomY & 8B8oHC.
author | Tony Vroon <chainsaw@gentoo.org> |
---|---|
date | Sat, 18 Apr 2009 21:28:56 +0100 |
parents | 95b34f46a231 |
children | 919ec26c66c3 |
files | src/wma/wma.c |
diffstat | 1 files changed, 17 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/wma/wma.c Sat Apr 18 19:06:20 2009 +0100 +++ b/src/wma/wma.c Sat Apr 18 21:28:56 2009 +0100 @@ -165,7 +165,7 @@ static int wma_is_our_fd(char *filename, VFSFile *fd) { - AVCodec *codec2; + AVCodec *codec2 = NULL; AVCodecContext *c2 = NULL; AVFormatContext *ic2 = NULL; int wma_idx2; @@ -174,9 +174,16 @@ for(wma_idx2 = 0; wma_idx2 < ic2->nb_streams; wma_idx2++) { c2 = &ic2->streams[wma_idx2]->codec; - if(c2->codec_type == CODEC_TYPE_AUDIO) break; + if(c2->codec_type == CODEC_TYPE_AUDIO) + { + av_find_stream_info(ic2); + codec2 = avcodec_find_decoder(c2->codec_id); + if (codec2) break; + } } + if (!codec2) return 0; + av_find_stream_info(ic2); codec2 = avcodec_find_decoder(c2->codec_id); @@ -300,7 +307,7 @@ static void wma_play_file(InputPlayback *playback) { - AVCodec *codec; + AVCodec *codec = NULL; AVCodecContext *c = NULL; AVFormatContext *ic = NULL; uint8_t *inbuf_ptr; @@ -313,14 +320,15 @@ for(wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) { c = &ic->streams[wma_idx]->codec; - if(c->codec_type == CODEC_TYPE_AUDIO) break; + if(c->codec_type == CODEC_TYPE_AUDIO) + { + av_find_stream_info(ic); + codec = avcodec_find_decoder(c->codec_id); + if (codec) break; + } } - av_find_stream_info(ic); - - codec = avcodec_find_decoder(c->codec_id); - - if(!codec) return; + if (!codec) return; if(avcodec_open(c, codec) < 0) return;