# HG changeset patch # User Tony Vroon # Date 1240086536 -3600 # Node ID a3734dd60d7a2eddd9f528196d6a634ac502fc7d # Parent 95b34f46a231cea98decbd2a677d1f4390020ff2 Change the flow of codec probing to avoid the possibility of a null pointer dereference. From code analysis, unique IDs mPqomY & 8B8oHC. diff -r 95b34f46a231 -r a3734dd60d7a src/wma/wma.c --- 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;