Coverage Report

Created: 2026-12-01 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/flac/include/share/alloc.h
Line
Count
Source
1
/* alloc - Convenience routines for safely allocating memory
2
 * Copyright (C) 2007-2009  Josh Coalson
3
 * Copyright (C) 2011-2025  Xiph.Org Foundation
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 *
9
 * - Redistributions of source code must retain the above copyright
10
 * notice, this list of conditions and the following disclaimer.
11
 *
12
 * - Redistributions in binary form must reproduce the above copyright
13
 * notice, this list of conditions and the following disclaimer in the
14
 * documentation and/or other materials provided with the distribution.
15
 *
16
 * - Neither the name of the Xiph.org Foundation nor the names of its
17
 * contributors may be used to endorse or promote products derived from
18
 * this software without specific prior written permission.
19
 *
20
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
 * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
24
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
 */
32
33
#ifndef FLAC__SHARE__ALLOC_H
34
#define FLAC__SHARE__ALLOC_H
35
36
#ifdef HAVE_CONFIG_H
37
#  include <config.h>
38
#endif
39
40
/* WATCHOUT: for c++ you may have to #define __STDC_LIMIT_MACROS 1 real early
41
 * before #including this file,  otherwise SIZE_MAX might not be defined
42
 */
43
44
#include <limits.h> /* for SIZE_MAX */
45
#ifdef HAVE_STDINT_H
46
#include <stdint.h> /* for SIZE_MAX in case limits.h didn't get it */
47
#endif
48
#include <stdlib.h> /* for size_t, malloc(), etc */
49
#include "share/compat.h"
50
51
#ifndef SIZE_MAX
52
# ifndef SIZE_T_MAX
53
#  ifdef _MSC_VER
54
#   ifdef _WIN64
55
#    define SIZE_T_MAX FLAC__U64L(0xffffffffffffffff)
56
#   else
57
#    define SIZE_T_MAX 0xffffffff
58
#   endif
59
#  else
60
#   error
61
#  endif
62
# endif
63
# define SIZE_MAX SIZE_T_MAX
64
#endif
65
66
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
67
68
extern int alloc_check_threshold, alloc_check_counter, alloc_check_keep_failing;
69
70
41.5M
static inline int alloc_check(void) {
71
41.5M
  if(alloc_check_threshold == INT32_MAX)
72
38.8M
    return 0;
73
2.72M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
1.91k
    return 1;
75
2.72M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.65k
    return 1;
77
2.72M
  else {
78
2.72M
    return 0;
79
2.72M
  }
80
41.5M
}
encode.c:alloc_check
Line
Count
Source
70
171k
static inline int alloc_check(void) {
71
171k
  if(alloc_check_threshold == INT32_MAX)
72
149k
    return 0;
73
21.5k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
46
    return 1;
75
21.4k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
21.4k
  else {
78
21.4k
    return 0;
79
21.4k
  }
80
171k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
190k
static inline int alloc_check(void) {
71
190k
  if(alloc_check_threshold == INT32_MAX)
72
189k
    return 0;
73
1.10k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
11
    return 1;
75
1.09k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.09k
  else {
78
1.09k
    return 0;
79
1.09k
  }
80
190k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
81.5k
static inline int alloc_check(void) {
71
81.5k
  if(alloc_check_threshold == INT32_MAX)
72
80.3k
    return 0;
73
1.23k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
28
    return 1;
75
1.20k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
139
    return 1;
77
1.06k
  else {
78
1.06k
    return 0;
79
1.06k
  }
80
81.5k
}
picture.c:alloc_check
Line
Count
Source
70
10.4k
static inline int alloc_check(void) {
71
10.4k
  if(alloc_check_threshold == INT32_MAX)
72
8.18k
    return 0;
73
2.28k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
35
    return 1;
75
2.24k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
327
    return 1;
77
1.91k
  else {
78
1.91k
    return 0;
79
1.91k
  }
80
10.4k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
49.9k
static inline int alloc_check(void) {
71
49.9k
  if(alloc_check_threshold == INT32_MAX)
72
48.3k
    return 0;
73
1.60k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
1.60k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.60k
  else {
78
1.60k
    return 0;
79
1.60k
  }
80
49.9k
}
format.c:alloc_check
Line
Count
Source
70
4.50M
static inline int alloc_check(void) {
71
4.50M
  if(alloc_check_threshold == INT32_MAX)
72
3.29M
    return 0;
73
1.20M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
222
    return 1;
75
1.20M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.20M
  else {
78
1.20M
    return 0;
79
1.20M
  }
80
4.50M
}
metadata_iterators.c:alloc_check
Line
Count
Source
70
27.4M
static inline int alloc_check(void) {
71
27.4M
  if(alloc_check_threshold == INT32_MAX)
72
27.4M
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
27.4M
}
metadata_object.c:alloc_check
Line
Count
Source
70
3.15M
static inline int alloc_check(void) {
71
3.15M
  if(alloc_check_threshold == INT32_MAX)
72
3.13M
    return 0;
73
22.6k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
139
    return 1;
75
22.5k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
473
    return 1;
77
22.0k
  else {
78
22.0k
    return 0;
79
22.0k
  }
80
3.15M
}
stream_decoder.c:alloc_check
Line
Count
Source
70
1.50M
static inline int alloc_check(void) {
71
1.50M
  if(alloc_check_threshold == INT32_MAX)
72
1.25M
    return 0;
73
250k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
562
    return 1;
75
250k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
584
    return 1;
77
249k
  else {
78
249k
    return 0;
79
249k
  }
80
1.50M
}
stream_encoder.c:alloc_check
Line
Count
Source
70
400k
static inline int alloc_check(void) {
71
400k
  if(alloc_check_threshold == INT32_MAX)
72
299k
    return 0;
73
100k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
102
    return 1;
75
100k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
126
    return 1;
77
100k
  else {
78
100k
    return 0;
79
100k
  }
80
400k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
153k
static inline int alloc_check(void) {
71
153k
  if(alloc_check_threshold == INT32_MAX)
72
124k
    return 0;
73
28.7k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
85
    return 1;
75
28.6k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
28.6k
  else {
78
28.6k
    return 0;
79
28.6k
  }
80
153k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
5.80k
static inline int alloc_check(void) {
71
5.80k
  if(alloc_check_threshold == INT32_MAX)
72
4.59k
    return 0;
73
1.21k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
34
    return 1;
75
1.17k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.17k
  else {
78
1.17k
    return 0;
79
1.17k
  }
80
5.80k
}
bitwriter.c:alloc_check
Line
Count
Source
70
43.9k
static inline int alloc_check(void) {
71
43.9k
  if(alloc_check_threshold == INT32_MAX)
72
41.5k
    return 0;
73
2.42k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
63
    return 1;
75
2.35k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
2.35k
  else {
78
2.35k
    return 0;
79
2.35k
  }
80
43.9k
}
md5.c:alloc_check
Line
Count
Source
70
42.7k
static inline int alloc_check(void) {
71
42.7k
  if(alloc_check_threshold == INT32_MAX)
72
35.0k
    return 0;
73
7.70k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
296
    return 1;
75
7.41k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
3
    return 1;
77
7.41k
  else {
78
7.41k
    return 0;
79
7.41k
  }
80
42.7k
}
memory.c:alloc_check
Line
Count
Source
70
3.78M
static inline int alloc_check(void) {
71
3.78M
  if(alloc_check_threshold == INT32_MAX)
72
2.71M
    return 0;
73
1.07M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
291
    return 1;
75
1.07M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.07M
  else {
78
1.07M
    return 0;
79
1.07M
  }
80
3.78M
}
operations.c:alloc_check
Line
Count
Source
70
6.14k
static inline int alloc_check(void) {
71
6.14k
  if(alloc_check_threshold == INT32_MAX)
72
6.14k
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
6.14k
}
options.c:alloc_check
Line
Count
Source
70
4
static inline int alloc_check(void) {
71
4
  if(alloc_check_threshold == INT32_MAX)
72
4
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
4
}
utils.c:alloc_check
Line
Count
Source
70
48.5k
static inline int alloc_check(void) {
71
48.5k
  if(alloc_check_threshold == INT32_MAX)
72
48.5k
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
48.5k
}
Unexecuted instantiation: alloc.c:alloc_check
metadata.cpp:alloc_check()
Line
Count
Source
70
10.1k
static inline int alloc_check(void) {
71
10.1k
  if(alloc_check_threshold == INT32_MAX)
72
10.1k
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
10.1k
}
81
82
#endif
83
84
/* avoid malloc()ing 0 bytes, see:
85
 * https://www.securecoding.cert.org/confluence/display/seccode/MEM04-A.+Do+not+make+assumptions+about+the+result+of+allocating+0+bytes?focusedCommentId=5407003
86
*/
87
88
static inline void *safe_malloc_(size_t size)
89
34.8M
{
90
34.8M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
34.8M
  if(alloc_check())
93
1.14k
    return NULL;
94
34.8M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
34.8M
  if(!size)
97
6.45k
    size++;
98
34.8M
  return malloc(size);
99
34.8M
}
Unexecuted instantiation: encode.c:safe_malloc_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_
Unexecuted instantiation: tool_flac.c:safe_malloc_
Unexecuted instantiation: utf8.c:safe_malloc_
iconvert.c:safe_malloc_
Line
Count
Source
89
678
{
90
678
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
678
  if(alloc_check())
93
0
    return NULL;
94
678
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
678
  if(!size)
97
0
    size++;
98
678
  return malloc(size);
99
678
}
picture.c:safe_malloc_
Line
Count
Source
89
10.4k
{
90
10.4k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
10.4k
  if(alloc_check())
93
362
    return NULL;
94
10.1k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
10.1k
  if(!size)
97
0
    size++;
98
10.1k
  return malloc(size);
99
10.4k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_
Unexecuted instantiation: format.c:safe_malloc_
metadata_iterators.c:safe_malloc_
Line
Count
Source
89
27.4M
{
90
27.4M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
27.4M
  if(alloc_check())
93
0
    return NULL;
94
27.4M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
27.4M
  if(!size)
97
0
    size++;
98
27.4M
  return malloc(size);
99
27.4M
}
metadata_object.c:safe_malloc_
Line
Count
Source
89
3.06M
{
90
3.06M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.06M
  if(alloc_check())
93
443
    return NULL;
94
3.06M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.06M
  if(!size)
97
0
    size++;
98
3.06M
  return malloc(size);
99
3.06M
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
528k
{
90
528k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
528k
  if(alloc_check())
93
15
    return NULL;
94
528k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
528k
  if(!size)
97
6.45k
    size++;
98
528k
  return malloc(size);
99
528k
}
Unexecuted instantiation: stream_encoder.c:safe_malloc_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_
ogg_helper.c:safe_malloc_
Line
Count
Source
89
5.80k
{
90
5.80k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.80k
  if(alloc_check())
93
34
    return NULL;
94
5.77k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.77k
  if(!size)
97
0
    size++;
98
5.77k
  return malloc(size);
99
5.80k
}
Unexecuted instantiation: bitwriter.c:safe_malloc_
md5.c:safe_malloc_
Line
Count
Source
89
296
{
90
296
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
296
  if(alloc_check())
93
3
    return NULL;
94
293
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
293
  if(!size)
97
0
    size++;
98
293
  return malloc(size);
99
296
}
memory.c:safe_malloc_
Line
Count
Source
89
3.78M
{
90
3.78M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.78M
  if(alloc_check())
93
291
    return NULL;
94
3.78M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.78M
  if(!size)
97
0
    size++;
98
3.78M
  return malloc(size);
99
3.78M
}
operations.c:safe_malloc_
Line
Count
Source
89
6.14k
{
90
6.14k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
6.14k
  if(alloc_check())
93
0
    return NULL;
94
6.14k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
6.14k
  if(!size)
97
0
    size++;
98
6.14k
  return malloc(size);
99
6.14k
}
Unexecuted instantiation: options.c:safe_malloc_
Unexecuted instantiation: utils.c:safe_malloc_
Unexecuted instantiation: alloc.c:safe_malloc_
metadata.cpp:safe_malloc_(unsigned long)
Line
Count
Source
89
10.1k
{
90
10.1k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
10.1k
  if(alloc_check())
93
0
    return NULL;
94
10.1k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
10.1k
  if(!size)
97
0
    size++;
98
10.1k
  return malloc(size);
99
10.1k
}
100
101
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
102
static inline void *malloc_(size_t size)
103
395k
{
104
  /* Fail if requested */
105
395k
  if(alloc_check())
106
118
    return NULL;
107
395k
  return malloc(size);
108
395k
}
Unexecuted instantiation: encode.c:malloc_
Unexecuted instantiation: foreign_metadata.c:malloc_
Unexecuted instantiation: tool_flac.c:malloc_
Unexecuted instantiation: utf8.c:malloc_
Unexecuted instantiation: iconvert.c:malloc_
Unexecuted instantiation: picture.c:malloc_
Unexecuted instantiation: replaygain_analysis.c:malloc_
Unexecuted instantiation: format.c:malloc_
Unexecuted instantiation: metadata_iterators.c:malloc_
Unexecuted instantiation: metadata_object.c:malloc_
stream_decoder.c:malloc_
Line
Count
Source
103
395k
{
104
  /* Fail if requested */
105
395k
  if(alloc_check())
106
118
    return NULL;
107
395k
  return malloc(size);
108
395k
}
Unexecuted instantiation: stream_encoder.c:malloc_
Unexecuted instantiation: ogg_decoder_aspect.c:malloc_
Unexecuted instantiation: ogg_helper.c:malloc_
Unexecuted instantiation: bitwriter.c:malloc_
Unexecuted instantiation: md5.c:malloc_
Unexecuted instantiation: memory.c:malloc_
Unexecuted instantiation: operations.c:malloc_
Unexecuted instantiation: options.c:malloc_
Unexecuted instantiation: utils.c:malloc_
Unexecuted instantiation: alloc.c:malloc_
Unexecuted instantiation: metadata.cpp:malloc_(unsigned long)
109
#else
110
#define malloc_ malloc
111
#endif
112
113
114
115
static inline void *safe_calloc_(size_t nmemb, size_t size)
116
1.04M
{
117
1.04M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
1.04M
  if(alloc_check())
120
1.38k
    return NULL;
121
1.04M
#endif
122
1.04M
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
1.04M
  return calloc(nmemb, size);
125
1.04M
}
Unexecuted instantiation: encode.c:safe_calloc_
Unexecuted instantiation: foreign_metadata.c:safe_calloc_
Unexecuted instantiation: tool_flac.c:safe_calloc_
Unexecuted instantiation: utf8.c:safe_calloc_
Unexecuted instantiation: iconvert.c:safe_calloc_
Unexecuted instantiation: picture.c:safe_calloc_
Unexecuted instantiation: replaygain_analysis.c:safe_calloc_
Unexecuted instantiation: format.c:safe_calloc_
Unexecuted instantiation: metadata_iterators.c:safe_calloc_
metadata_object.c:safe_calloc_
Line
Count
Source
116
83.9k
{
117
83.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
83.9k
  if(alloc_check())
120
159
    return NULL;
121
83.7k
#endif
122
83.7k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
83.7k
  return calloc(nmemb, size);
125
83.7k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
561k
{
117
561k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
561k
  if(alloc_check())
120
1.00k
    return NULL;
121
560k
#endif
122
560k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
560k
  return calloc(nmemb, size);
125
560k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
400k
{
117
400k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
400k
  if(alloc_check())
120
228
    return NULL;
121
400k
#endif
122
400k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
400k
  return calloc(nmemb, size);
125
400k
}
Unexecuted instantiation: ogg_decoder_aspect.c:safe_calloc_
Unexecuted instantiation: ogg_helper.c:safe_calloc_
Unexecuted instantiation: bitwriter.c:safe_calloc_
Unexecuted instantiation: md5.c:safe_calloc_
Unexecuted instantiation: memory.c:safe_calloc_
Unexecuted instantiation: operations.c:safe_calloc_
Unexecuted instantiation: options.c:safe_calloc_
Unexecuted instantiation: utils.c:safe_calloc_
Unexecuted instantiation: alloc.c:safe_calloc_
Unexecuted instantiation: metadata.cpp:safe_calloc_(unsigned long, unsigned long)
126
127
/*@@@@ there's probably a better way to prevent overflows when allocating untrusted sums but this works for now */
128
129
static inline void *safe_malloc_add_2op_(size_t size1, size_t size2)
130
34.5M
{
131
34.5M
  size2 += size1;
132
34.5M
  if(size2 < size1)
133
0
    return 0;
134
34.5M
  return safe_malloc_(size2);
135
34.5M
}
Unexecuted instantiation: encode.c:safe_malloc_add_2op_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_add_2op_
Unexecuted instantiation: tool_flac.c:safe_malloc_add_2op_
Unexecuted instantiation: utf8.c:safe_malloc_add_2op_
iconvert.c:safe_malloc_add_2op_
Line
Count
Source
130
678
{
131
678
  size2 += size1;
132
678
  if(size2 < size1)
133
0
    return 0;
134
678
  return safe_malloc_(size2);
135
678
}
picture.c:safe_malloc_add_2op_
Line
Count
Source
130
8.47k
{
131
8.47k
  size2 += size1;
132
8.47k
  if(size2 < size1)
133
0
    return 0;
134
8.47k
  return safe_malloc_(size2);
135
8.47k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_add_2op_
Unexecuted instantiation: format.c:safe_malloc_add_2op_
metadata_iterators.c:safe_malloc_add_2op_
Line
Count
Source
130
27.4M
{
131
27.4M
  size2 += size1;
132
27.4M
  if(size2 < size1)
133
0
    return 0;
134
27.4M
  return safe_malloc_(size2);
135
27.4M
}
metadata_object.c:safe_malloc_add_2op_
Line
Count
Source
130
2.86M
{
131
2.86M
  size2 += size1;
132
2.86M
  if(size2 < size1)
133
0
    return 0;
134
2.86M
  return safe_malloc_(size2);
135
2.86M
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
508k
{
131
508k
  size2 += size1;
132
508k
  if(size2 < size1)
133
0
    return 0;
134
508k
  return safe_malloc_(size2);
135
508k
}
Unexecuted instantiation: stream_encoder.c:safe_malloc_add_2op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_add_2op_
Unexecuted instantiation: ogg_helper.c:safe_malloc_add_2op_
Unexecuted instantiation: bitwriter.c:safe_malloc_add_2op_
Unexecuted instantiation: md5.c:safe_malloc_add_2op_
memory.c:safe_malloc_add_2op_
Line
Count
Source
130
3.78M
{
131
3.78M
  size2 += size1;
132
3.78M
  if(size2 < size1)
133
0
    return 0;
134
3.78M
  return safe_malloc_(size2);
135
3.78M
}
Unexecuted instantiation: operations.c:safe_malloc_add_2op_
Unexecuted instantiation: options.c:safe_malloc_add_2op_
Unexecuted instantiation: utils.c:safe_malloc_add_2op_
Unexecuted instantiation: alloc.c:safe_malloc_add_2op_
metadata.cpp:safe_malloc_add_2op_(unsigned long, unsigned long)
Line
Count
Source
130
10.1k
{
131
10.1k
  size2 += size1;
132
10.1k
  if(size2 < size1)
133
0
    return 0;
134
10.1k
  return safe_malloc_(size2);
135
10.1k
}
136
137
static inline void *safe_malloc_add_3op_(size_t size1, size_t size2, size_t size3)
138
0
{
139
0
  size2 += size1;
140
0
  if(size2 < size1)
141
0
    return 0;
142
0
  size3 += size2;
143
0
  if(size3 < size2)
144
0
    return 0;
145
0
  return safe_malloc_(size3);
146
0
}
Unexecuted instantiation: encode.c:safe_malloc_add_3op_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_add_3op_
Unexecuted instantiation: tool_flac.c:safe_malloc_add_3op_
Unexecuted instantiation: utf8.c:safe_malloc_add_3op_
Unexecuted instantiation: iconvert.c:safe_malloc_add_3op_
Unexecuted instantiation: picture.c:safe_malloc_add_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_add_3op_
Unexecuted instantiation: format.c:safe_malloc_add_3op_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_add_3op_
Unexecuted instantiation: metadata_object.c:safe_malloc_add_3op_
Unexecuted instantiation: stream_decoder.c:safe_malloc_add_3op_
Unexecuted instantiation: stream_encoder.c:safe_malloc_add_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_add_3op_
Unexecuted instantiation: ogg_helper.c:safe_malloc_add_3op_
Unexecuted instantiation: bitwriter.c:safe_malloc_add_3op_
Unexecuted instantiation: md5.c:safe_malloc_add_3op_
Unexecuted instantiation: memory.c:safe_malloc_add_3op_
Unexecuted instantiation: operations.c:safe_malloc_add_3op_
Unexecuted instantiation: options.c:safe_malloc_add_3op_
Unexecuted instantiation: utils.c:safe_malloc_add_3op_
Unexecuted instantiation: alloc.c:safe_malloc_add_3op_
Unexecuted instantiation: metadata.cpp:safe_malloc_add_3op_(unsigned long, unsigned long, unsigned long)
147
148
static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
149
9.28k
{
150
9.28k
  size2 += size1;
151
9.28k
  if(size2 < size1)
152
0
    return 0;
153
9.28k
  size3 += size2;
154
9.28k
  if(size3 < size2)
155
0
    return 0;
156
9.28k
  size4 += size3;
157
9.28k
  if(size4 < size3)
158
0
    return 0;
159
9.28k
  return safe_malloc_(size4);
160
9.28k
}
Unexecuted instantiation: encode.c:safe_malloc_add_4op_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_add_4op_
Unexecuted instantiation: tool_flac.c:safe_malloc_add_4op_
Unexecuted instantiation: utf8.c:safe_malloc_add_4op_
Unexecuted instantiation: iconvert.c:safe_malloc_add_4op_
Unexecuted instantiation: picture.c:safe_malloc_add_4op_
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_add_4op_
Unexecuted instantiation: format.c:safe_malloc_add_4op_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_add_4op_
metadata_object.c:safe_malloc_add_4op_
Line
Count
Source
149
9.28k
{
150
9.28k
  size2 += size1;
151
9.28k
  if(size2 < size1)
152
0
    return 0;
153
9.28k
  size3 += size2;
154
9.28k
  if(size3 < size2)
155
0
    return 0;
156
9.28k
  size4 += size3;
157
9.28k
  if(size4 < size3)
158
0
    return 0;
159
9.28k
  return safe_malloc_(size4);
160
9.28k
}
Unexecuted instantiation: stream_decoder.c:safe_malloc_add_4op_
Unexecuted instantiation: stream_encoder.c:safe_malloc_add_4op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_add_4op_
Unexecuted instantiation: ogg_helper.c:safe_malloc_add_4op_
Unexecuted instantiation: bitwriter.c:safe_malloc_add_4op_
Unexecuted instantiation: md5.c:safe_malloc_add_4op_
Unexecuted instantiation: memory.c:safe_malloc_add_4op_
Unexecuted instantiation: operations.c:safe_malloc_add_4op_
Unexecuted instantiation: options.c:safe_malloc_add_4op_
Unexecuted instantiation: utils.c:safe_malloc_add_4op_
Unexecuted instantiation: alloc.c:safe_malloc_add_4op_
Unexecuted instantiation: metadata.cpp:safe_malloc_add_4op_(unsigned long, unsigned long, unsigned long, unsigned long)
161
162
void *safe_malloc_mul_2op_(size_t size1, size_t size2) ;
163
164
static inline void *safe_malloc_mul_3op_(size_t size1, size_t size2, size_t size3)
165
0
{
166
0
  if(!size1 || !size2 || !size3)
167
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
168
0
  if(size1 > SIZE_MAX / size2)
169
0
    return 0;
170
0
  size1 *= size2;
171
0
  if(size1 > SIZE_MAX / size3)
172
0
    return 0;
173
0
  return malloc_(size1*size3);
174
0
}
Unexecuted instantiation: encode.c:safe_malloc_mul_3op_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_mul_3op_
Unexecuted instantiation: tool_flac.c:safe_malloc_mul_3op_
Unexecuted instantiation: utf8.c:safe_malloc_mul_3op_
Unexecuted instantiation: iconvert.c:safe_malloc_mul_3op_
Unexecuted instantiation: picture.c:safe_malloc_mul_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_mul_3op_
Unexecuted instantiation: format.c:safe_malloc_mul_3op_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_mul_3op_
Unexecuted instantiation: metadata_object.c:safe_malloc_mul_3op_
Unexecuted instantiation: stream_decoder.c:safe_malloc_mul_3op_
Unexecuted instantiation: stream_encoder.c:safe_malloc_mul_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_mul_3op_
Unexecuted instantiation: ogg_helper.c:safe_malloc_mul_3op_
Unexecuted instantiation: bitwriter.c:safe_malloc_mul_3op_
Unexecuted instantiation: md5.c:safe_malloc_mul_3op_
Unexecuted instantiation: memory.c:safe_malloc_mul_3op_
Unexecuted instantiation: operations.c:safe_malloc_mul_3op_
Unexecuted instantiation: options.c:safe_malloc_mul_3op_
Unexecuted instantiation: utils.c:safe_malloc_mul_3op_
Unexecuted instantiation: alloc.c:safe_malloc_mul_3op_
Unexecuted instantiation: metadata.cpp:safe_malloc_mul_3op_(unsigned long, unsigned long, unsigned long)
175
176
/* size1*size2 + size3 */
177
static inline void *safe_malloc_mul2add_(size_t size1, size_t size2, size_t size3)
178
0
{
179
0
  if(!size1 || !size2)
180
0
    return safe_malloc_(size3);
181
0
  if(size1 > SIZE_MAX / size2)
182
0
    return 0;
183
0
  return safe_malloc_add_2op_(size1*size2, size3);
184
0
}
Unexecuted instantiation: encode.c:safe_malloc_mul2add_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_mul2add_
Unexecuted instantiation: tool_flac.c:safe_malloc_mul2add_
Unexecuted instantiation: utf8.c:safe_malloc_mul2add_
Unexecuted instantiation: iconvert.c:safe_malloc_mul2add_
Unexecuted instantiation: picture.c:safe_malloc_mul2add_
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_mul2add_
Unexecuted instantiation: format.c:safe_malloc_mul2add_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_mul2add_
Unexecuted instantiation: metadata_object.c:safe_malloc_mul2add_
Unexecuted instantiation: stream_decoder.c:safe_malloc_mul2add_
Unexecuted instantiation: stream_encoder.c:safe_malloc_mul2add_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_mul2add_
Unexecuted instantiation: ogg_helper.c:safe_malloc_mul2add_
Unexecuted instantiation: bitwriter.c:safe_malloc_mul2add_
Unexecuted instantiation: md5.c:safe_malloc_mul2add_
Unexecuted instantiation: memory.c:safe_malloc_mul2add_
Unexecuted instantiation: operations.c:safe_malloc_mul2add_
Unexecuted instantiation: options.c:safe_malloc_mul2add_
Unexecuted instantiation: utils.c:safe_malloc_mul2add_
Unexecuted instantiation: alloc.c:safe_malloc_mul2add_
Unexecuted instantiation: metadata.cpp:safe_malloc_mul2add_(unsigned long, unsigned long, unsigned long)
185
186
/* size1 * (size2 + size3) */
187
static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
188
395k
{
189
395k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
395k
  size2 += size3;
192
395k
  if(size2 < size3)
193
0
    return 0;
194
395k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
395k
  return malloc_(size1*size2);
197
395k
}
Unexecuted instantiation: encode.c:safe_malloc_muladd2_
Unexecuted instantiation: foreign_metadata.c:safe_malloc_muladd2_
Unexecuted instantiation: tool_flac.c:safe_malloc_muladd2_
Unexecuted instantiation: utf8.c:safe_malloc_muladd2_
Unexecuted instantiation: iconvert.c:safe_malloc_muladd2_
Unexecuted instantiation: picture.c:safe_malloc_muladd2_
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_muladd2_
Unexecuted instantiation: format.c:safe_malloc_muladd2_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_muladd2_
Unexecuted instantiation: metadata_object.c:safe_malloc_muladd2_
stream_decoder.c:safe_malloc_muladd2_
Line
Count
Source
188
395k
{
189
395k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
395k
  size2 += size3;
192
395k
  if(size2 < size3)
193
0
    return 0;
194
395k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
395k
  return malloc_(size1*size2);
197
395k
}
Unexecuted instantiation: stream_encoder.c:safe_malloc_muladd2_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_muladd2_
Unexecuted instantiation: ogg_helper.c:safe_malloc_muladd2_
Unexecuted instantiation: bitwriter.c:safe_malloc_muladd2_
Unexecuted instantiation: md5.c:safe_malloc_muladd2_
Unexecuted instantiation: memory.c:safe_malloc_muladd2_
Unexecuted instantiation: operations.c:safe_malloc_muladd2_
Unexecuted instantiation: options.c:safe_malloc_muladd2_
Unexecuted instantiation: utils.c:safe_malloc_muladd2_
Unexecuted instantiation: alloc.c:safe_malloc_muladd2_
Unexecuted instantiation: metadata.cpp:safe_malloc_muladd2_(unsigned long, unsigned long, unsigned long)
198
199
static inline void *safe_realloc_(void *ptr, size_t size)
200
4.67M
{
201
4.67M
  void *oldptr;
202
4.67M
  void *newptr;
203
4.67M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4.67M
  if(alloc_check() && size > 0) {
206
540
    free(ptr);
207
540
    return NULL;
208
540
  }
209
4.67M
#endif
210
4.67M
  oldptr = ptr;
211
4.67M
  newptr = realloc(ptr, size);
212
4.67M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4.67M
  return newptr;
215
4.67M
}
Unexecuted instantiation: encode.c:safe_realloc_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_
Unexecuted instantiation: tool_flac.c:safe_realloc_
Unexecuted instantiation: utf8.c:safe_realloc_
Unexecuted instantiation: iconvert.c:safe_realloc_
Unexecuted instantiation: picture.c:safe_realloc_
replaygain_analysis.c:safe_realloc_
Line
Count
Source
200
49.9k
{
201
49.9k
  void *oldptr;
202
49.9k
  void *newptr;
203
49.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
49.9k
  if(alloc_check() && size > 0) {
206
3
    free(ptr);
207
3
    return NULL;
208
3
  }
209
49.9k
#endif
210
49.9k
  oldptr = ptr;
211
49.9k
  newptr = realloc(ptr, size);
212
49.9k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
49.9k
  return newptr;
215
49.9k
}
format.c:safe_realloc_
Line
Count
Source
200
4.50M
{
201
4.50M
  void *oldptr;
202
4.50M
  void *newptr;
203
4.50M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4.50M
  if(alloc_check() && size > 0) {
206
222
    free(ptr);
207
222
    return NULL;
208
222
  }
209
4.50M
#endif
210
4.50M
  oldptr = ptr;
211
4.50M
  newptr = realloc(ptr, size);
212
4.50M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4.50M
  return newptr;
215
4.50M
}
Unexecuted instantiation: metadata_iterators.c:safe_realloc_
Unexecuted instantiation: metadata_object.c:safe_realloc_
stream_decoder.c:safe_realloc_
Line
Count
Source
200
18.7k
{
201
18.7k
  void *oldptr;
202
18.7k
  void *newptr;
203
18.7k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
18.7k
  if(alloc_check() && size > 0) {
206
11
    free(ptr);
207
11
    return NULL;
208
11
  }
209
18.7k
#endif
210
18.7k
  oldptr = ptr;
211
18.7k
  newptr = realloc(ptr, size);
212
18.7k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
18.7k
  return newptr;
215
18.7k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_
ogg_decoder_aspect.c:safe_realloc_
Line
Count
Source
200
13.1k
{
201
13.1k
  void *oldptr;
202
13.1k
  void *newptr;
203
13.1k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
13.1k
  if(alloc_check() && size > 0) {
206
8
    free(ptr);
207
8
    return NULL;
208
8
  }
209
13.1k
#endif
210
13.1k
  oldptr = ptr;
211
13.1k
  newptr = realloc(ptr, size);
212
13.1k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
13.1k
  return newptr;
215
13.1k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
42.4k
{
201
42.4k
  void *oldptr;
202
42.4k
  void *newptr;
203
42.4k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
42.4k
  if(alloc_check() && size > 0) {
206
296
    free(ptr);
207
296
    return NULL;
208
296
  }
209
42.1k
#endif
210
42.1k
  oldptr = ptr;
211
42.1k
  newptr = realloc(ptr, size);
212
42.1k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
42.1k
  return newptr;
215
42.4k
}
Unexecuted instantiation: memory.c:safe_realloc_
Unexecuted instantiation: operations.c:safe_realloc_
options.c:safe_realloc_
Line
Count
Source
200
4
{
201
4
  void *oldptr;
202
4
  void *newptr;
203
4
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
4
#endif
210
4
  oldptr = ptr;
211
4
  newptr = realloc(ptr, size);
212
4
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4
  return newptr;
215
4
}
utils.c:safe_realloc_
Line
Count
Source
200
48.5k
{
201
48.5k
  void *oldptr;
202
48.5k
  void *newptr;
203
48.5k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
48.5k
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
48.5k
#endif
210
48.5k
  oldptr = ptr;
211
48.5k
  newptr = realloc(ptr, size);
212
48.5k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
48.5k
  return newptr;
215
48.5k
}
Unexecuted instantiation: alloc.c:safe_realloc_
Unexecuted instantiation: metadata.cpp:safe_realloc_(void*, unsigned long)
216
217
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
218
static inline void *realloc_(void *ptr, size_t size)
219
636k
{
220
  /* Fail if requested */
221
636k
  if(alloc_check())
222
377
    return NULL;
223
635k
  return realloc(ptr, size);
224
636k
}
encode.c:realloc_
Line
Count
Source
219
171k
{
220
  /* Fail if requested */
221
171k
  if(alloc_check())
222
47
    return NULL;
223
171k
  return realloc(ptr, size);
224
171k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
190k
{
220
  /* Fail if requested */
221
190k
  if(alloc_check())
222
12
    return NULL;
223
190k
  return realloc(ptr, size);
224
190k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
80.9k
{
220
  /* Fail if requested */
221
80.9k
  if(alloc_check())
222
167
    return NULL;
223
80.7k
  return realloc(ptr, size);
224
80.9k
}
Unexecuted instantiation: picture.c:realloc_
Unexecuted instantiation: replaygain_analysis.c:realloc_
Unexecuted instantiation: format.c:realloc_
Unexecuted instantiation: metadata_iterators.c:realloc_
metadata_object.c:realloc_
Line
Count
Source
219
8.97k
{
220
  /* Fail if requested */
221
8.97k
  if(alloc_check())
222
10
    return NULL;
223
8.96k
  return realloc(ptr, size);
224
8.97k
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
140k
{
220
  /* Fail if requested */
221
140k
  if(alloc_check())
222
78
    return NULL;
223
140k
  return realloc(ptr, size);
224
140k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
43.9k
{
220
  /* Fail if requested */
221
43.9k
  if(alloc_check())
222
63
    return NULL;
223
43.9k
  return realloc(ptr, size);
224
43.9k
}
Unexecuted instantiation: md5.c:realloc_
Unexecuted instantiation: memory.c:realloc_
Unexecuted instantiation: operations.c:realloc_
Unexecuted instantiation: options.c:realloc_
Unexecuted instantiation: utils.c:realloc_
Unexecuted instantiation: alloc.c:realloc_
Unexecuted instantiation: metadata.cpp:realloc_(void*, unsigned long)
225
#else
226
#define realloc_ realloc
227
#endif
228
229
230
static inline void *safe_realloc_nofree_add_2op_(void *ptr, size_t size1, size_t size2)
231
89.8k
{
232
89.8k
  size2 += size1;
233
89.8k
  if(size2 < size1)
234
0
    return 0;
235
89.8k
  return realloc_(ptr, size2);
236
89.8k
}
Unexecuted instantiation: encode.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_add_2op_
iconvert.c:safe_realloc_nofree_add_2op_
Line
Count
Source
231
80.9k
{
232
80.9k
  size2 += size1;
233
80.9k
  if(size2 < size1)
234
0
    return 0;
235
80.9k
  return realloc_(ptr, size2);
236
80.9k
}
Unexecuted instantiation: picture.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: format.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_add_2op_
metadata_object.c:safe_realloc_nofree_add_2op_
Line
Count
Source
231
8.97k
{
232
8.97k
  size2 += size1;
233
8.97k
  if(size2 < size1)
234
0
    return 0;
235
8.97k
  return realloc_(ptr, size2);
236
8.97k
}
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: md5.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: options.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_add_2op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_add_2op_(void*, unsigned long, unsigned long)
237
238
static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
239
48.5k
{
240
48.5k
  size2 += size1;
241
48.5k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
48.5k
  size3 += size2;
246
48.5k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
48.5k
  return safe_realloc_(ptr, size3);
251
48.5k
}
Unexecuted instantiation: encode.c:safe_realloc_add_3op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_add_3op_
Unexecuted instantiation: tool_flac.c:safe_realloc_add_3op_
Unexecuted instantiation: utf8.c:safe_realloc_add_3op_
Unexecuted instantiation: iconvert.c:safe_realloc_add_3op_
Unexecuted instantiation: picture.c:safe_realloc_add_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_add_3op_
Unexecuted instantiation: format.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata_object.c:safe_realloc_add_3op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_add_3op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_add_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_add_3op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_add_3op_
Unexecuted instantiation: bitwriter.c:safe_realloc_add_3op_
Unexecuted instantiation: md5.c:safe_realloc_add_3op_
Unexecuted instantiation: memory.c:safe_realloc_add_3op_
Unexecuted instantiation: operations.c:safe_realloc_add_3op_
Unexecuted instantiation: options.c:safe_realloc_add_3op_
utils.c:safe_realloc_add_3op_
Line
Count
Source
239
48.5k
{
240
48.5k
  size2 += size1;
241
48.5k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
48.5k
  size3 += size2;
246
48.5k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
48.5k
  return safe_realloc_(ptr, size3);
251
48.5k
}
Unexecuted instantiation: alloc.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata.cpp:safe_realloc_add_3op_(void*, unsigned long, unsigned long, unsigned long)
252
253
static inline void *safe_realloc_nofree_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
254
0
{
255
0
  size2 += size1;
256
0
  if(size2 < size1)
257
0
    return 0;
258
0
  size3 += size2;
259
0
  if(size3 < size2)
260
0
    return 0;
261
0
  return realloc_(ptr, size3);
262
0
}
Unexecuted instantiation: encode.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: picture.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: format.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: md5.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: options.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_add_3op_(void*, unsigned long, unsigned long, unsigned long)
263
264
static inline void *safe_realloc_nofree_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
265
0
{
266
0
  size2 += size1;
267
0
  if(size2 < size1)
268
0
    return 0;
269
0
  size3 += size2;
270
0
  if(size3 < size2)
271
0
    return 0;
272
0
  size4 += size3;
273
0
  if(size4 < size3)
274
0
    return 0;
275
0
  return realloc_(ptr, size4);
276
0
}
Unexecuted instantiation: encode.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: picture.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: format.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: md5.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: options.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_add_4op_(void*, unsigned long, unsigned long, unsigned long, unsigned long)
277
278
static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
279
31.8k
{
280
31.8k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
31.8k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
31.8k
  return safe_realloc_(ptr, size1*size2);
287
31.8k
}
Unexecuted instantiation: encode.c:safe_realloc_mul_2op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_mul_2op_
Unexecuted instantiation: tool_flac.c:safe_realloc_mul_2op_
Unexecuted instantiation: utf8.c:safe_realloc_mul_2op_
Unexecuted instantiation: iconvert.c:safe_realloc_mul_2op_
Unexecuted instantiation: picture.c:safe_realloc_mul_2op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_mul_2op_
Unexecuted instantiation: format.c:safe_realloc_mul_2op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_mul_2op_
Unexecuted instantiation: metadata_object.c:safe_realloc_mul_2op_
stream_decoder.c:safe_realloc_mul_2op_
Line
Count
Source
279
18.7k
{
280
18.7k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
18.7k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
18.7k
  return safe_realloc_(ptr, size1*size2);
287
18.7k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_mul_2op_
ogg_decoder_aspect.c:safe_realloc_mul_2op_
Line
Count
Source
279
13.1k
{
280
13.1k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
13.1k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
13.1k
  return safe_realloc_(ptr, size1*size2);
287
13.1k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_mul_2op_
Unexecuted instantiation: bitwriter.c:safe_realloc_mul_2op_
Unexecuted instantiation: md5.c:safe_realloc_mul_2op_
Unexecuted instantiation: memory.c:safe_realloc_mul_2op_
Unexecuted instantiation: operations.c:safe_realloc_mul_2op_
options.c:safe_realloc_mul_2op_
Line
Count
Source
279
4
{
280
4
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
4
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
4
  return safe_realloc_(ptr, size1*size2);
287
4
}
Unexecuted instantiation: utils.c:safe_realloc_mul_2op_
Unexecuted instantiation: alloc.c:safe_realloc_mul_2op_
Unexecuted instantiation: metadata.cpp:safe_realloc_mul_2op_(void*, unsigned long, unsigned long)
288
289
static inline void *safe_realloc_nofree_mul_2op_(void *ptr, size_t size1, size_t size2)
290
546k
{
291
546k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
546k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
546k
  return realloc_(ptr, size1*size2);
296
546k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
171k
{
291
171k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
171k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
171k
  return realloc_(ptr, size1*size2);
296
171k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
190k
{
291
190k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
190k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
190k
  return realloc_(ptr, size1*size2);
296
190k
}
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: picture.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: format.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_mul_2op_
ogg_decoder_aspect.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
140k
{
291
140k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
140k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
140k
  return realloc_(ptr, size1*size2);
296
140k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
43.9k
{
291
43.9k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
43.9k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
43.9k
  return realloc_(ptr, size1*size2);
296
43.9k
}
Unexecuted instantiation: md5.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: options.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_mul_2op_(void*, unsigned long, unsigned long)
297
298
/* size1 * (size2 + size3) */
299
static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
300
0
{
301
0
  if(!size1 || (!size2 && !size3))
302
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
303
0
  size2 += size3;
304
0
  if(size2 < size3) {
305
0
    free(ptr);
306
0
    return 0;
307
0
  }
308
0
  return safe_realloc_mul_2op_(ptr, size1, size2);
309
0
}
Unexecuted instantiation: encode.c:safe_realloc_muladd2_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_muladd2_
Unexecuted instantiation: tool_flac.c:safe_realloc_muladd2_
Unexecuted instantiation: utf8.c:safe_realloc_muladd2_
Unexecuted instantiation: iconvert.c:safe_realloc_muladd2_
Unexecuted instantiation: picture.c:safe_realloc_muladd2_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_muladd2_
Unexecuted instantiation: format.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata_object.c:safe_realloc_muladd2_
Unexecuted instantiation: stream_decoder.c:safe_realloc_muladd2_
Unexecuted instantiation: stream_encoder.c:safe_realloc_muladd2_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_muladd2_
Unexecuted instantiation: ogg_helper.c:safe_realloc_muladd2_
Unexecuted instantiation: bitwriter.c:safe_realloc_muladd2_
Unexecuted instantiation: md5.c:safe_realloc_muladd2_
Unexecuted instantiation: memory.c:safe_realloc_muladd2_
Unexecuted instantiation: operations.c:safe_realloc_muladd2_
Unexecuted instantiation: options.c:safe_realloc_muladd2_
Unexecuted instantiation: utils.c:safe_realloc_muladd2_
Unexecuted instantiation: alloc.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata.cpp:safe_realloc_muladd2_(void*, unsigned long, unsigned long, unsigned long)
310
311
/* size1 * (size2 + size3) */
312
static inline void *safe_realloc_nofree_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
313
361k
{
314
361k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
361k
  size2 += size3;
317
361k
  if(size2 < size3)
318
0
    return 0;
319
361k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
361k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
171k
{
314
171k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
171k
  size2 += size3;
317
171k
  if(size2 < size3)
318
0
    return 0;
319
171k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
171k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
190k
{
314
190k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
190k
  size2 += size3;
317
190k
  if(size2 < size3)
318
0
    return 0;
319
190k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
190k
}
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: picture.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: format.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: md5.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: memory.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: operations.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: options.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: utils.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_muladd2_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_muladd2_(void*, unsigned long, unsigned long, unsigned long)
321
322
#endif