shithub: opus-tools

Download patch

ref: 98f3ddc8e94b8be31ebdeac52805a93cfab395e7
parent: 7b92abb9f17b4ec813344cad2aa931d17926c7b2
author: Mark Harris <[email protected]>
date: Sat Nov 11 13:23:03 EST 2023

opusinfo: Silence GCC 12 compiler warning

src/opusinfo.c: In function 'check_xiph_comment':
src/opusinfo.c:297:32: warning: argument 1 range [18446744072098938880, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  297 |          data=(unsigned char *)malloc(data_sz*sizeof(*data));
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--- a/src/opusinfo.c
+++ b/src/opusinfo.c
@@ -122,17 +122,13 @@
 
     for(j=0; j < sep-comment; j++) {
         if(comment[j] < 0x20 || comment[j] > 0x7D) {
-            oi_warn(_("WARNING: Invalid comment fieldname in "
+            oi_warn(_("WARNING: Invalid comment tag in "
                    "comment %d (stream %d): \"%s\"\n"),
                    i, stream->num, comment);
-            broken = 1;
-            break;
+            return;
         }
     }
 
-    if(broken)
-        return;
-
     val = (unsigned char *)comment;
 
     j = sep-comment+1;
@@ -286,15 +282,15 @@
          }
          len>>=2;
          data_sz=3*len;
-         if(data_sz > 0) {
+         if(data_sz > 2) {
              if(comment[comment_length - 1] == '=') {
                  data_sz--;
+                 if(comment[comment_length - 2] == '=') {
+                     data_sz--;
+                 }
              }
-             if(comment[comment_length - 2] == '=') {
-                 data_sz--;
-             }
          }
-         data=(unsigned char *)malloc(data_sz*sizeof(*data));
+         data=data_sz>0?(unsigned char *)malloc(data_sz*sizeof(*data)):NULL;
          for (j = 0; j < len; j++) {
              ogg_uint32_t value;
              int          k;