From bd607f5c4791d8215092b5a0c92c07159ca0d85f Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" <tterribe@xiph.org> Date: Sun, 3 Jul 2016 18:50:09 -0700 Subject: [PATCH] Add missing NULL check to opus_tags_parse(). According to the API, you can pass in a NULL OpusTags object to simply check if the comment packet is valid, without storing the parsed results. However, the additions to store binary metadata in commit 0221ca95fc58 did not check for this. Fixes Coverity CID 149873. --- src/info.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/info.c b/src/info.c index e244230..d7ead3f 100644 --- a/src/info.c +++ b/src/info.c @@ -205,10 +205,12 @@ static int opus_tags_parse_impl(OpusTags *_tags, } if(len>0&&(_data[0]&1)){ if(len>(opus_uint32)INT_MAX)return OP_EFAULT; - _tags->user_comments[ncomments]=(char *)_ogg_malloc(len); - if(OP_UNLIKELY(_tags->user_comments[ncomments]==NULL))return OP_EFAULT; - memcpy(_tags->user_comments[ncomments],_data,len); - _tags->comment_lengths[ncomments]=(int)len; + if(_tags!=NULL){ + _tags->user_comments[ncomments]=(char *)_ogg_malloc(len); + if(OP_UNLIKELY(_tags->user_comments[ncomments]==NULL))return OP_EFAULT; + memcpy(_tags->user_comments[ncomments],_data,len); + _tags->comment_lengths[ncomments]=(int)len; + } } return 0; } -- GitLab