From 66a8c15828453b24d39776e5eb4d363c0b28e8dd Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" <tterribe@xiph.org> Date: Sun, 3 Jul 2016 18:43:26 -0700 Subject: [PATCH] Fix NULL check in opus_tags_add_comment(). In 0221ca95fc58 the allocation result went from being stored directly in "_tags->user_comments[ncomments]" to being stored in the temporary "comment". However, the NULL check for allocation failure was not updated to match. This meant this function would almost always fail, unless you had added binary metadata first. Fixes Coverity CID 149874. --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 55e2906..e244230 100644 --- a/src/info.c +++ b/src/info.c @@ -306,7 +306,7 @@ int opus_tags_add_comment(OpusTags *_tags,const char *_comment){ if(OP_UNLIKELY(ret<0))return ret; comment_len=(int)strlen(_comment); comment=op_strdup_with_len(_comment,comment_len); - if(OP_UNLIKELY(_tags->user_comments[ncomments]==NULL))return OP_EFAULT; + if(OP_UNLIKELY(comment==NULL))return OP_EFAULT; _tags->user_comments[ncomments]=comment; _tags->comment_lengths[ncomments]=comment_len; _tags->comments=ncomments+1; -- GitLab