ref: bd607f5c4791d8215092b5a0c92c07159ca0d85f
parent: 66a8c15828453b24d39776e5eb4d363c0b28e8dd
author: Timothy B. Terriberry <tterribe@xiph.org>
date: Sun Jul 3 14:50:09 EDT 2016
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.
--- a/src/info.c
+++ b/src/info.c
@@ -205,10 +205,12 @@
}
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;
}