Commit bd607f5c authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

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
 0221ca95 did not check for this.

Fixes Coverity CID 149873.
parent 66a8c158
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment