Fixed findings

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-476): [#def1]
wavpack-5.7.0-build/wavpack-5.7.0/src/wavpack_local.h:14: included_from: Included from here.
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c: scope_hint: In function 'write_metadata_block'
wavpack-5.7.0-build/wavpack-5.7.0/include/wavpack.h:100:29: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'block_buff'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
#   98|       int64_t tmp = (value);                      \
#   99|       if (tmp < 0)                                \
#  100|->         (hdr).total_samples = (uint32_t) -1;    \
#  101|       else {                                      \
#  102|           tmp += (tmp / 0xffffffffLL);            \

Error: GCC_ANALYZER_WARNING (CWE-476): [#def2]
wavpack-5.7.0-build/wavpack-5.7.0/include/wavpack.h:103:29: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'block_buff'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1512:9: note: in expansion of macro 'SET_TOTAL_SAMPLES'
#  101|       else {                                      \
#  102|           tmp += (tmp / 0xffffffffLL);            \
#  103|->         (hdr).total_samples = (uint32_t) tmp;   \
#  104|           (hdr).total_samples_u8 =                \
#  105|               (unsigned char) (tmp >> 32);        \

Error: GCC_ANALYZER_WARNING (CWE-476): [#def3]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c: scope_hint: In function 'decorr_mono_pass'
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c:99:29: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'out_samples'
#   97|               update_weight (dpp->weight_A, dpp->delta, sam_A, left);
#   98|               dpp->sum_A += dpp->weight_A;
#   99|->             out_samples [0] = left;
#  100|               in_samples += dir;
#  101|               out_samples += dir;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def4]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c: scope_hint: In function 'analyze_mono'
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c:433:5: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'info.sampleptrs[*wps.mask_decorr]' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  431|   
#  432|       memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
#  433|->     memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 4);
#  434|   
#  435|       for (i = 0; i < info.nterms && info.dps [i].term; ++i)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def5]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c:433:29: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'info.sampleptrs[0]'
#  431|   
#  432|       memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
#  433|->     memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 4);
#  434|   
#  435|       for (i = 0; i < info.nterms && info.dps [i].term; ++i)

Error: GCC_ANALYZER_WARNING (CWE-688): [#def6]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c: scope_hint: In function 'execute_mono'
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c:605:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc((long unsigned int)buf_size)' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  603|   
#  604|           while (1) {
#  605|->         memcpy (temp_buffer [0], noisy_buffer ? noisy_buffer : samples, buf_size);
#  606|           CLEARA (save_decorr_passes);
#  607|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def7]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra1.c:640:13: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'best_buffer' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  638|   
#  639|           if (size < best_size) {
#  640|->             memcpy (best_buffer, temp_buffer [j&1], buf_size);
#  641|               memcpy (wps->decorr_passes, save_decorr_passes, sizeof (struct decorr_pass) * MAX_NTERMS);
#  642|               wps->num_terms = nterms;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def8]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c: scope_hint: In function 'analyze_stereo'
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c:597:5: warning[-Wanalyzer-null-argument]: use of NULL 'samples' where non-null expected
<built-in>: note: argument 2 of '__builtin_memcpy' must be non-null
#  595|   
#  596|       memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
#  597|->     memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 8);
#  598|   
#  599|       for (i = 0; i < info.nterms && info.dps [i].term; ++i)

Error: GCC_ANALYZER_WARNING (CWE-688): [#def9]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c:597:5: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'info.sampleptrs[*wps.best_decorr]' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  595|   
#  596|       memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
#  597|->     memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 8);
#  598|   
#  599|       for (i = 0; i < info.nterms && info.dps [i].term; ++i)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def10]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c:597:29: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value 'info.sampleptrs[0]'
#  595|   
#  596|       memcpy (info.dps, wps->decorr_passes, sizeof (info.dps));
#  597|->     memcpy (info.sampleptrs [0], samples, wps->wphdr.block_samples * 8);
#  598|   
#  599|       for (i = 0; i < info.nterms && info.dps [i].term; ++i)

Error: GCC_ANALYZER_WARNING (CWE-688): [#def11]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c: scope_hint: In function 'execute_stereo'
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c:801:21: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'js_buffer' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  799|   
#  800|                       lptr = js_buffer = malloc (buf_size);
#  801|->                     memcpy (js_buffer, noisy_buffer ? noisy_buffer : samples, buf_size);
#  802|   
#  803|                       while (cnt--) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def12]
wavpack-5.7.0-build/wavpack-5.7.0/src/extra2.c:812:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc((long unsigned int)buf_size)' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  810|               }
#  811|               else
#  812|->                 memcpy (temp_buffer [0], noisy_buffer ? noisy_buffer : samples, buf_size);
#  813|   
#  814|               CLEARA (save_decorr_passes);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def13]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_filename.c: scope_hint: In function 'WavpackOpenFileInput'
wavpack-5.7.0-build/wavpack-5.7.0/src/open_filename.c:302:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'in2filename' where non-null expected
<built-in>: note: argument 1 of '__builtin_strcpy' must be non-null
#  300|           char *in2filename = malloc (strlen (infilename) + 10);
#  301|   
#  302|->         strcpy (in2filename, infilename);
#  303|           strcat (in2filename, "c");
#  304|           wvc_id = fopen_func (in2filename, "rb");

Error: GCC_ANALYZER_WARNING (CWE-476): [#def14]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_legacy.c: scope_hint: In function 'WavpackOpenFileInputEx'
wavpack-5.7.0-build/wavpack-5.7.0/src/open_legacy.c:103:26: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'trans_wv'
#  101|       if (wv_id) {
#  102|           trans_wv = (WavpackReaderTranslator *)malloc (sizeof (WavpackReaderTranslator));
#  103|->         trans_wv->reader = reader;
#  104|           trans_wv->id = wv_id;
#  105|       }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def15]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_legacy.c:109:27: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'trans_wvc'
#  107|       if (wvc_id) {
#  108|           trans_wvc = (WavpackReaderTranslator *)malloc (sizeof (WavpackReaderTranslator));
#  109|->         trans_wvc->reader = reader;
#  110|           trans_wvc->id = wvc_id;
#  111|       }

Error: GCC_ANALYZER_WARNING (CWE-688): [#def16]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c: scope_hint: In function 'WavpackOpenRawDecoder'
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:151:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'raw_wv' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  149|   
#  150|           raw_wv = malloc (sizeof (WavpackRawContext));
#  151|->         memset (raw_wv, 0, sizeof (WavpackRawContext));
#  152|   
#  153|           if (corr_data && corr_size) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def17]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:155:13: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'raw_wvc' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  153|           if (corr_data && corr_size) {
#  154|               raw_wvc = malloc (sizeof (WavpackRawContext));
#  155|->             memset (raw_wvc, 0, sizeof (WavpackRawContext));
#  156|           }
#  157|   

Error: GCC_ANALYZER_WARNING (CWE-476): [#def18]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:205:31: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wphdr'
#  203|                   memset (wphdr, 0, sizeof (WavpackHeader));
#  204|                   memcpy (wphdr->ckID, "wvpk", 4);
#  205|->                 wphdr->ckSize = sizeof (WavpackHeader) - 8 + block_size;
#  206|                   SET_TOTAL_SAMPLES (*wphdr, block_samples);
#  207|                   wphdr->block_samples = block_samples;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def19]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:214:34: warning[-Wanalyzer-malloc-leak]: leak of '<unknown>'
#  212|   
#  213|                   raw_wv->num_segments += 2;
#  214|->                 raw_wv->segments = realloc (raw_wv->segments, sizeof (RawSegment) * raw_wv->num_segments);
#  215|                   raw_wv->segments [msi].dptr = raw_wv->segments [msi].sptr = (unsigned char *) wphdr;
#  216|                   raw_wv->segments [msi].eptr = raw_wv->segments [msi].dptr + sizeof (WavpackHeader);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def20]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:215:75: warning[-Wanalyzer-null-dereference]: dereference of NULL '0'
#  213|                   raw_wv->num_segments += 2;
#  214|                   raw_wv->segments = realloc (raw_wv->segments, sizeof (RawSegment) * raw_wv->num_segments);
#  215|->                 raw_wv->segments [msi].dptr = raw_wv->segments [msi].sptr = (unsigned char *) wphdr;
#  216|                   raw_wv->segments [msi].eptr = raw_wv->segments [msi].dptr + sizeof (WavpackHeader);
#  217|                   raw_wv->segments [msi++].free_required = 1;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def21]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:252:35: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wphdr'
#  250|                       memset (wphdr, 0, sizeof (WavpackHeader));
#  251|                       memcpy (wphdr->ckID, "wvpk", 4);
#  252|->                     wphdr->ckSize = sizeof (WavpackHeader) - 8 + block_size;
#  253|                       SET_TOTAL_SAMPLES (*wphdr, block_samples);
#  254|                       wphdr->block_samples = block_samples;

Error: GCC_ANALYZER_WARNING (CWE-416): [#def22]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:260:28: warning[-Wanalyzer-use-after-free]: use after 'free' of 'raw_wvc'
#  258|                       WavpackLittleEndianToNative (wphdr, WavpackHeaderFormat);
#  259|   
#  260|->                     raw_wvc->num_segments += 2;
#  261|                       raw_wvc->segments = realloc (raw_wvc->segments, sizeof (RawSegment) * raw_wvc->num_segments);
#  262|                       raw_wvc->segments [csi].dptr = raw_wvc->segments [csi].sptr = (unsigned char *) wphdr;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def23]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:262:81: warning[-Wanalyzer-null-dereference]: dereference of NULL '0'
#  260|                       raw_wvc->num_segments += 2;
#  261|                       raw_wvc->segments = realloc (raw_wvc->segments, sizeof (RawSegment) * raw_wvc->num_segments);
#  262|->                     raw_wvc->segments [csi].dptr = raw_wvc->segments [csi].sptr = (unsigned char *) wphdr;
#  263|                       raw_wvc->segments [csi].eptr = raw_wvc->segments [csi].dptr + sizeof (WavpackHeader);
#  264|                       raw_wvc->segments [csi++].free_required = 1;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def24]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:285:34: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'raw_wv'
#  283|               raw_wv = malloc (sizeof (WavpackRawContext));
#  284|               memset (raw_wv, 0, sizeof (WavpackRawContext));
#  285|->             raw_wv->num_segments = 1;
#  286|               raw_wv->segments = malloc (sizeof (RawSegment) * raw_wv->num_segments);
#  287|               raw_wv->segments [0].dptr = raw_wv->segments [0].sptr = main_data;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def25]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:287:67: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'malloc(32)'
#  285|               raw_wv->num_segments = 1;
#  286|               raw_wv->segments = malloc (sizeof (RawSegment) * raw_wv->num_segments);
#  287|->             raw_wv->segments [0].dptr = raw_wv->segments [0].sptr = main_data;
#  288|               raw_wv->segments [0].eptr = raw_wv->segments [0].dptr + main_size;
#  289|               raw_wv->segments [0].free_required = 0;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def26]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:295:35: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'raw_wvc'
#  293|               raw_wvc = malloc (sizeof (WavpackRawContext));
#  294|               memset (raw_wvc, 0, sizeof (WavpackRawContext));
#  295|->             raw_wvc->num_segments = 1;
#  296|               raw_wvc->segments = malloc (sizeof (RawSegment) * raw_wvc->num_segments);
#  297|               raw_wvc->segments [0].dptr = raw_wvc->segments [0].sptr = corr_data;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def27]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_raw.c:297:69: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'malloc(32)'
#  295|               raw_wvc->num_segments = 1;
#  296|               raw_wvc->segments = malloc (sizeof (RawSegment) * raw_wvc->num_segments);
#  297|->             raw_wvc->segments [0].dptr = raw_wvc->segments [0].sptr = corr_data;
#  298|               raw_wvc->segments [0].eptr = raw_wvc->segments [0].dptr + corr_size;
#  299|               raw_wvc->segments [0].free_required = 0;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def28]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_utils.c: scope_hint: In function 'read_channel_identities'
wavpack-5.7.0-build/wavpack-5.7.0/src/open_utils.c:565:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*wpc.channel_identities' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  563|       if (!wpc->channel_identities) {
#  564|           wpc->channel_identities = (unsigned char *)malloc (wpmd->byte_length + 1);
#  565|->         memcpy (wpc->channel_identities, wpmd->data, wpmd->byte_length);
#  566|           wpc->channel_identities [wpmd->byte_length] = 0;
#  567|       }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def29]
wavpack-5.7.0-build/wavpack-5.7.0/src/open_utils.c: scope_hint: In function 'read_sample_rate'
wavpack-5.7.0-build/wavpack-5.7.0/src/open_utils.c:681:45: warning[-Wanalyzer-null-dereference]: dereference of NULL 'byteptr'
#  679|   
#  680|       if (bytecnt == 3 || bytecnt == 4) {
#  681|->         wpc->config.sample_rate = (int32_t) *byteptr++;
#  682|           wpc->config.sample_rate |= (int32_t) *byteptr++ << 8;
#  683|           wpc->config.sample_rate |= (int32_t) *byteptr++ << 16;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def30]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_decorr_terms'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:110:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'byteptr'
#  108|   
#  109|       for (dpp = wps->decorr_passes; tcount--; ++dpp)
#  110|->         *byteptr++ = ((dpp->term + 5) & 0x1f) | ((dpp->delta << 5) & 0xe0);
#  111|   
#  112|       wpmd->byte_length = (int32_t)(byteptr - (char *) wpmd->data);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def31]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_int32_info'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:281:16: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  279|       byteptr = wpmd->data = malloc (4);
#  280|       wpmd->id = ID_INT32_INFO;
#  281|->     *byteptr++ = wps->int32_sent_bits;
#  282|       *byteptr++ = wps->int32_zeros;
#  283|       *byteptr++ = wps->int32_ones;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def32]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_float_info'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:294:16: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  292|       byteptr = wpmd->data = malloc (4);
#  293|       wpmd->id = ID_FLOAT_INFO;
#  294|->     *byteptr++ = wps->float_flags;
#  295|       *byteptr++ = wps->float_shift;
#  296|       *byteptr++ = wps->float_max_exp;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def33]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_channel_info'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:314:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  312|   
#  313|       if (wps->wpc->num_streams > OLD_MAX_STREAMS) {       // if > 8 streams, use 6 or 7 bytes (breaks old decoders
#  314|->         *byteptr++ = wps->wpc->config.num_channels - 1;  // that could only handle 8 streams) and allow (in theory)
#  315|           *byteptr++ = wps->wpc->num_streams - 1;          // up to 4096 channels
#  316|           *byteptr++ = (((wps->wpc->num_streams - 1) >> 4) & 0xf0) | (((wps->wpc->config.num_channels - 1) >> 8) & 0xf);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def34]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:325:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  323|       }
#  324|       else {                                          // otherwise use only 1 to 5 bytes
#  325|->         *byteptr++ = wps->wpc->config.num_channels;
#  326|   
#  327|           while (mask) {

Error: GCC_ANALYZER_WARNING (CWE-476): [#def35]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_config_info'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:361:16: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  359|       byteptr = wpmd->data = malloc (8);
#  360|       wpmd->id = ID_CONFIG_BLOCK;
#  361|->     *byteptr++ = (char) (wps->wpc->config.flags >> 8);
#  362|       *byteptr++ = (char) (wps->wpc->config.flags >> 16);
#  363|       *byteptr++ = (char) (wps->wpc->config.flags >> 24);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def36]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_new_config_info'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:388:20: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  386|   
#  387|       if (wps->wpc->file_format || (wps->wpc->config.qmode & 0xff) || wps->wpc->channel_layout) {
#  388|->         *byteptr++ = (char) wps->wpc->file_format;
#  389|           *byteptr++ = (char) wps->wpc->config.qmode;
#  390|   

Error: GCC_ANALYZER_WARNING (CWE-476): [#def37]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'write_sample_rate'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:431:16: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'wpmd.data'
#  429|       byteptr = wpmd->data = malloc (4);
#  430|       wpmd->id = ID_SAMPLE_RATE;
#  431|->     *byteptr++ = (char) (wps->wpc->config.sample_rate);
#  432|       *byteptr++ = (char) (wps->wpc->config.sample_rate >> 8);
#  433|       *byteptr++ = (char) (wps->wpc->config.sample_rate >> 16);

Error: GCC_ANALYZER_WARNING (CWE-688): [#def38]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c: scope_hint: In function 'pack_samples'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack.c:1109:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'saved_buffer' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1107|       if (repack_possible && !(flags & HYBRID_FLAG)) {
# 1108|           saved_buffer = malloc (sample_count * sizeof (int32_t) * (flags & MONO_DATA ? 1 : 2));
# 1109|->         memcpy (saved_buffer, buffer, sample_count * sizeof (int32_t) * (flags & MONO_DATA ? 1 : 2));
# 1110|       }
# 1111|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def39]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c: scope_hint: In function 'calculate_probabilities'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:205:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'probs' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  203|   
#  204|       if (max_hits == 0) {
#  205|->         memset (probs, 0, sizeof (*probs) * 256);
#  206|           memset (prob_sums, 0, sizeof (*prob_sums) * 256);
#  207|           return;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def40]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:206:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'prob_sums' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  204|       if (max_hits == 0) {
#  205|           memset (probs, 0, sizeof (*probs) * 256);
#  206|->         memset (prob_sums, 0, sizeof (*prob_sums) * 256);
#  207|           return;
#  208|       }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def41]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:237:27: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'prob_sums'
#  235|                   value = 0;
#  236|   
#  237|->             prob_sums [i] = sum_values += value;
#  238|               probs [i] = value;
#  239|           }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def42]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:238:23: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'probs'
#  236|   
#  237|               prob_sums [i] = sum_values += value;
#  238|->             probs [i] = value;
#  239|           }
#  240|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def43]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c: scope_hint: In function 'encode_buffer_fast'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:311:5: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'histogram' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  309|       history_bins = 1 << history_bits;
#  310|       histogram = malloc (sizeof (*histogram) * history_bins);
#  311|->     memset (histogram, 0, sizeof (*histogram) * history_bins);
#  312|       probabilities = malloc (sizeof (*probabilities) * history_bins);
#  313|       summed_probabilities = malloc (sizeof (*summed_probabilities) * history_bins);

Error: GCC_ANALYZER_WARNING (CWE-457): [#def44]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:333:65: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value '*<unknown>[255]'
#  331|       for (p0 = 0; p0 < history_bins; p0++) {
#  332|           calculate_probabilities (histogram [p0], probabilities [p0], summed_probabilities [p0]);
#  333|->         total_summed_probabilities += summed_probabilities [p0] [255];
#  334|       }
#  335|   

Error: GCC_ANALYZER_WARNING (CWE-476): [#def45]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c: scope_hint: In function 'init_ptable'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_dsd.c:457:19: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'table'
#  455|   
#  456|       for (i = 0; i < PTABLE_BINS/2; ++i) {
#  457|->         table [i] = value;
#  458|           table [PTABLE_BINS-1-i] = 0x100ffff - value;
#  459|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def46]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c: scope_hint: In function 'pack_streams'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1167:13: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'wps_copy' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1165|               WavpackStream *wps_copy = malloc (sizeof (WavpackStream));
# 1166|   
# 1167|->             memcpy (wps_copy, wps, sizeof (WavpackStream));
# 1168|   
# 1169|               // If there is a discontinuity (i.e., the previous block is not done, so we can't get any

Error: GCC_ANALYZER_WARNING (CWE-688): [#def47]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1178:13: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc((long unsigned int)(block_samples * <unknown>))' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1176|   
# 1177|               wps_copy->sample_buffer = malloc (block_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));
# 1178|->             memcpy (wps_copy->sample_buffer, wps->sample_buffer, block_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));
# 1179|   
# 1180|               if (wps->discontinuous && wps->pre_sample_buffer && wps->num_pre_samples) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def48]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1182:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc((long unsigned int)(*wps.num_pre_samples * <unknown>))' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1180|               if (wps->discontinuous && wps->pre_sample_buffer && wps->num_pre_samples) {
# 1181|                   wps_copy->pre_sample_buffer = malloc (wps->num_pre_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));
# 1182|->                 memcpy (wps_copy->pre_sample_buffer, wps->pre_sample_buffer, wps->num_pre_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));
# 1183|               }
# 1184|               else {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def49]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1191:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc(1024)' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1189|               if (wps->dsd.ptable) {
# 1190|                   wps_copy->dsd.ptable = malloc (256 * sizeof (*wps->dsd.ptable));
# 1191|->                 memcpy (wps_copy->dsd.ptable, wps->dsd.ptable, 256 * sizeof (*wps->dsd.ptable));
# 1192|               }
# 1193|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def50]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1244:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*wps.pre_sample_buffer' where non-null expected
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:22: included_from: Included from here.
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1822:5: note: in expansion of macro 'wp_mutex_release'
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1242|   
# 1243|               if (wps->wpc->block_samples > wps->wpc->max_pre_samples) {
# 1244|->                 memcpy (wps->pre_sample_buffer,
# 1245|                       wps->sample_buffer + (wps->wpc->block_samples - wps->wpc->max_pre_samples) * (wps->wphdr.flags & MONO_FLAG ? 1 : 2),
# 1246|                       wps->wpc->max_pre_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));

Error: GCC_ANALYZER_WARNING (CWE-688): [#def51]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1251:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*wps.pre_sample_buffer' where non-null expected
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1822:5: note: in expansion of macro 'wp_mutex_release'
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1249|               }
# 1250|               else {
# 1251|->                 memcpy (wps->pre_sample_buffer, wps->sample_buffer, wps->wpc->block_samples * (wps->wphdr.flags & MONO_FLAG ? 4 : 8));
# 1252|                   wps->num_pre_samples = wps->wpc->block_samples;
# 1253|               }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def52]
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c: scope_hint: In function 'worker_threads_create'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1841:36: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL '*wpc.workers'
wavpack-5.7.0-build/wavpack-5.7.0/src/pack_utils.c:1835:9: note: in expansion of macro 'wp_mutex_init'
# 1839|   
# 1840|           for (i = 0; i < wpc->num_workers; ++i) {
# 1841|->             wpc->workers [i].mutex = &wpc->mutex;
# 1842|               wpc->workers [i].global_cond = &wpc->global_cond;
# 1843|               wpc->workers [i].workers_ready = &wpc->workers_ready;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def53]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c: scope_hint: In function 'init_dsd_block_fast'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:159:5: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*wps.dsd.value_lookup' where non-null expected
<built-in>: note: argument 1 of '__builtin_memset' must be non-null
#  157|       lb_ptr = wps->dsd.lookup_buffer = (unsigned char *)malloc (wps->dsd.history_bins * MAX_BYTES_PER_BIN);
#  158|       wps->dsd.value_lookup = (unsigned char **)malloc (sizeof (*wps->dsd.value_lookup) * wps->dsd.history_bins);
#  159|->     memset (wps->dsd.value_lookup, 0, sizeof (*wps->dsd.value_lookup) * wps->dsd.history_bins);
#  160|       wps->dsd.summed_probabilities = (uint16_t (*)[256])malloc (sizeof (*wps->dsd.summed_probabilities) * wps->dsd.history_bins);
#  161|       wps->dsd.probabilities = (unsigned char (*)[256])malloc (sizeof (*wps->dsd.probabilities) * wps->dsd.history_bins);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def54]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:176:31: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'outptr'
#  174|   
#  175|                   while (outptr < outend && zcount--)
#  176|->                     *outptr++ = 0;
#  177|               }
#  178|               else if (code)

Error: GCC_ANALYZER_WARNING (CWE-476): [#def55]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:179:27: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'outptr'
#  177|               }
#  178|               else if (code)
#  179|->                 *outptr++ = code;
#  180|               else
#  181|                   break;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def56]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:188:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL '*wps.dsd.probabilities' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  186|       }
#  187|       else if (wps->dsd.endptr - wps->dsd.byteptr > (int) sizeof (*wps->dsd.probabilities) * wps->dsd.history_bins) {
#  188|->         memcpy (wps->dsd.probabilities, wps->dsd.byteptr, sizeof (*wps->dsd.probabilities) * wps->dsd.history_bins);
#  189|           wps->dsd.byteptr += sizeof (*wps->dsd.probabilities) * wps->dsd.history_bins;
#  190|       }

Error: GCC_ANALYZER_WARNING (CWE-457): [#def57]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:198:96: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value '*<unknown>[i]'
#  196|   
#  197|           for (sum_values = i = 0; i < 256; ++i)
#  198|->             wps->dsd.summed_probabilities [bi] [i] = sum_values += wps->dsd.probabilities [bi] [i];
#  199|   
#  200|           if (sum_values) {

Error: GCC_ANALYZER_WARNING (CWE-476): [#def58]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c: scope_hint: In function 'init_ptable'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_dsd.c:308:19: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'table'
#  306|   
#  307|       for (i = 0; i < PTABLE_BINS/2; ++i) {
#  308|->         table [i] = value;
#  309|           table [PTABLE_BINS-1-i] = 0x100ffff - value;
#  310|   

Error: COMPILER_WARNING: [#def59]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_seek.c: scope_hint: In function 'find_header'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_seek.c:306:59: warning[-Wuse-after-free]: pointer 'ep_95' used after 'free'
#  306 |                         return reader->get_pos (id) - (ep - sp + 4);
#      |                                                        ~~~^~~~
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_seek.c:305:25: note: call to 'free' here
#  305 |                         free (buffer);
#      |                         ^~~~~~~~~~~~~
#  304|                       if (wphdr->block_samples && (wphdr->flags & INITIAL_BLOCK)) {
#  305|                           free (buffer);
#  306|->                         return reader->get_pos (id) - (ep - sp + 4);
#  307|                       }
#  308|   

Error: GCC_ANALYZER_WARNING (CWE-476): [#def60]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c: scope_hint: In function 'unpack_samples_interleave'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:68:23: warning[-Wanalyzer-null-dereference]: dereference of NULL 'src'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:19: included_from: Included from here.
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:504:9: note: in expansion of macro 'wp_mutex_release'
#   66|       if (wps->wphdr.flags & MONO_FLAG) {
#   67|           while (samcnt--) {
#   68|->             dst [0] = *src++;
#   69|               dst += num_channels;
#   70|           }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def61]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:77:27: warning[-Wanalyzer-null-dereference]: dereference of NULL 'src'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:504:9: note: in expansion of macro 'wp_mutex_release'
#   75|       else if (offset == num_channels - 1) {
#   76|           while (samcnt--) {
#   77|->             dst [0] = src [0];
#   78|               dst += num_channels;
#   79|               src += 2;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def62]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:87:23: warning[-Wanalyzer-null-dereference]: dereference of NULL 'src'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:504:9: note: in expansion of macro 'wp_mutex_release'
#   85|       else {
#   86|           while (samcnt--) {
#   87|->             dst [0] = *src++;
#   88|               dst [1] = *src++;
#   89|               dst += num_channels;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def63]
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c: scope_hint: In function 'worker_threads_create'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:594:36: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL '*wpc.workers'
wavpack-5.7.0-build/wavpack-5.7.0/src/unpack_utils.c:588:9: note: in expansion of macro 'wp_mutex_init'
#  592|   
#  593|           for (i = 0; i < wpc->num_workers; ++i) {
#  594|->             wpc->workers [i].mutex = &wpc->mutex;
#  595|               wpc->workers [i].global_cond = &wpc->global_cond;
#  596|               wpc->workers [i].workers_ready = &wpc->workers_ready;

Scan Properties

analyzer-version-clippy1.82.0
analyzer-version-cppcheck2.16.0
analyzer-version-gcc14.2.1
analyzer-version-gcc-analyzer15.0.0
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
diffbase-analyzer-version-clippy1.82.0
diffbase-analyzer-version-cppcheck2.16.0
diffbase-analyzer-version-gcc14.2.1
diffbase-analyzer-version-gcc-analyzer15.0.0
diffbase-analyzer-version-shellcheck0.10.0
diffbase-analyzer-version-unicontrol0.0.2
diffbase-enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
diffbase-exit-code0
diffbase-hostip-172-16-1-144.us-west-2.compute.internal
diffbase-mock-configfedora-rawhide-gcc-latest-x86_64
diffbase-project-namewavpack-5.7.0-10.fc42
diffbase-store-results-to/tmp/tmpwuow1e23/wavpack-5.7.0-10.fc42.tar.xz
diffbase-time-created2024-11-13 03:29:15
diffbase-time-finished2024-11-13 03:31:37
diffbase-toolcsmock
diffbase-tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmpwuow1e23/wavpack-5.7.0-10.fc42.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpwuow1e23/wavpack-5.7.0-10.fc42.src.rpm'
diffbase-tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-144.us-west-2.compute.internal
mock-configfedora-rawhide-gcc-latest-x86_64
project-namewavpack-5.7.0-3.fc41
store-results-to/tmp/tmpe3aznnyp/wavpack-5.7.0-3.fc41.tar.xz
time-created2024-11-13 03:26:31
time-finished2024-11-13 03:28:52
titleFixed findings
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-gcc-latest-x86_64' '-t' 'clippy,cppcheck,gcc,unicontrol,shellcheck' '-o' '/tmp/tmpe3aznnyp/wavpack-5.7.0-3.fc41.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install=gcc-latest' '--gcc-analyzer-bin=/opt/gcc-latest/bin/gcc' '/tmp/tmpe3aznnyp/wavpack-5.7.0-3.fc41.src.rpm'
tool-versioncsmock-3.7.1.20241107.094801.gb3f0f26.pr_192-1.el9