Coverage Report

Created: 2025-08-26 06:41

/src/flac/include/share/alloc.h
Line
Count
Source (jump to first uncovered line)
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
3.00M
static inline int alloc_check(void) {
71
3.00M
  if(alloc_check_threshold == INT32_MAX)
72
1.66M
    return 0;
73
1.33M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
900
    return 1;
75
1.33M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.02k
    return 1;
77
1.33M
  else {
78
1.33M
    return 0;
79
1.33M
  }
80
3.00M
}
encode.c:alloc_check
Line
Count
Source
70
201k
static inline int alloc_check(void) {
71
201k
  if(alloc_check_threshold == INT32_MAX)
72
183k
    return 0;
73
18.1k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
32
    return 1;
75
18.1k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
18.1k
  else {
78
18.1k
    return 0;
79
18.1k
  }
80
201k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
83.9k
static inline int alloc_check(void) {
71
83.9k
  if(alloc_check_threshold == INT32_MAX)
72
82.7k
    return 0;
73
1.19k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
12
    return 1;
75
1.18k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.18k
  else {
78
1.18k
    return 0;
79
1.18k
  }
80
83.9k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
1.92k
static inline int alloc_check(void) {
71
1.92k
  if(alloc_check_threshold == INT32_MAX)
72
895
    return 0;
73
1.02k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
10
    return 1;
75
1.01k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
149
    return 1;
77
869
  else {
78
869
    return 0;
79
869
  }
80
1.92k
}
picture.c:alloc_check
Line
Count
Source
70
4.53k
static inline int alloc_check(void) {
71
4.53k
  if(alloc_check_threshold == INT32_MAX)
72
2.72k
    return 0;
73
1.81k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
33
    return 1;
75
1.78k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
278
    return 1;
77
1.50k
  else {
78
1.50k
    return 0;
79
1.50k
  }
80
4.53k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
5.56k
static inline int alloc_check(void) {
71
5.56k
  if(alloc_check_threshold == INT32_MAX)
72
4.05k
    return 0;
73
1.51k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
1.50k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.50k
  else {
78
1.50k
    return 0;
79
1.50k
  }
80
5.56k
}
format.c:alloc_check
Line
Count
Source
70
1.15M
static inline int alloc_check(void) {
71
1.15M
  if(alloc_check_threshold == INT32_MAX)
72
553k
    return 0;
73
596k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
79
    return 1;
75
596k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
596k
  else {
78
596k
    return 0;
79
596k
  }
80
1.15M
}
Unexecuted instantiation: metadata_iterators.c:alloc_check
metadata_object.c:alloc_check
Line
Count
Source
70
58.8k
static inline int alloc_check(void) {
71
58.8k
  if(alloc_check_threshold == INT32_MAX)
72
52.5k
    return 0;
73
6.33k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
108
    return 1;
75
6.22k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
262
    return 1;
77
5.96k
  else {
78
5.96k
    return 0;
79
5.96k
  }
80
58.8k
}
stream_decoder.c:alloc_check
Line
Count
Source
70
308k
static inline int alloc_check(void) {
71
308k
  if(alloc_check_threshold == INT32_MAX)
72
183k
    return 0;
73
124k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
294
    return 1;
75
123k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
207
    return 1;
77
123k
  else {
78
123k
    return 0;
79
123k
  }
80
308k
}
stream_encoder.c:alloc_check
Line
Count
Source
70
131k
static inline int alloc_check(void) {
71
131k
  if(alloc_check_threshold == INT32_MAX)
72
96.4k
    return 0;
73
34.9k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
64
    return 1;
75
34.8k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
125
    return 1;
77
34.7k
  else {
78
34.7k
    return 0;
79
34.7k
  }
80
131k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
7.17k
static inline int alloc_check(void) {
71
7.17k
  if(alloc_check_threshold == INT32_MAX)
72
2.88k
    return 0;
73
4.29k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
10
    return 1;
75
4.28k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
4.28k
  else {
78
4.28k
    return 0;
79
4.28k
  }
80
7.17k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
879
static inline int alloc_check(void) {
71
879
  if(alloc_check_threshold == INT32_MAX)
72
754
    return 0;
73
125
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
122
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
122
  else {
78
122
    return 0;
79
122
  }
80
879
}
bitwriter.c:alloc_check
Line
Count
Source
70
29.0k
static inline int alloc_check(void) {
71
29.0k
  if(alloc_check_threshold == INT32_MAX)
72
27.7k
    return 0;
73
1.20k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
30
    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
29.0k
}
md5.c:alloc_check
Line
Count
Source
70
9.02k
static inline int alloc_check(void) {
71
9.02k
  if(alloc_check_threshold == INT32_MAX)
72
7.86k
    return 0;
73
1.16k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
5
    return 1;
75
1.15k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
3
    return 1;
77
1.15k
  else {
78
1.15k
    return 0;
79
1.15k
  }
80
9.02k
}
memory.c:alloc_check
Line
Count
Source
70
1.01M
static inline int alloc_check(void) {
71
1.01M
  if(alloc_check_threshold == INT32_MAX)
72
466k
    return 0;
73
545k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
217
    return 1;
75
544k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
544k
  else {
78
544k
    return 0;
79
544k
  }
80
1.01M
}
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
1.08M
{
90
1.08M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.08M
  if(alloc_check())
93
804
    return NULL;
94
1.08M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.08M
  if(!size)
97
39
    size++;
98
1.08M
  return malloc(size);
99
1.08M
}
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_
Unexecuted instantiation: iconvert.c:safe_malloc_
picture.c:safe_malloc_
Line
Count
Source
89
4.53k
{
90
4.53k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
4.53k
  if(alloc_check())
93
311
    return NULL;
94
4.22k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
4.22k
  if(!size)
97
0
    size++;
98
4.22k
  return malloc(size);
99
4.53k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_
Unexecuted instantiation: format.c:safe_malloc_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_
metadata_object.c:safe_malloc_
Line
Count
Source
89
47.2k
{
90
47.2k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
47.2k
  if(alloc_check())
93
263
    return NULL;
94
47.0k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
47.0k
  if(!size)
97
0
    size++;
98
47.0k
  return malloc(size);
99
47.2k
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
16.7k
{
90
16.7k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
16.7k
  if(alloc_check())
93
7
    return NULL;
94
16.7k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
16.7k
  if(!size)
97
39
    size++;
98
16.7k
  return malloc(size);
99
16.7k
}
Unexecuted instantiation: stream_encoder.c:safe_malloc_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_
ogg_helper.c:safe_malloc_
Line
Count
Source
89
879
{
90
879
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
879
  if(alloc_check())
93
3
    return NULL;
94
876
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
876
  if(!size)
97
0
    size++;
98
876
  return malloc(size);
99
879
}
Unexecuted instantiation: bitwriter.c:safe_malloc_
md5.c:safe_malloc_
Line
Count
Source
89
5
{
90
5
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5
  if(alloc_check())
93
3
    return NULL;
94
2
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
2
  if(!size)
97
0
    size++;
98
2
  return malloc(size);
99
5
}
memory.c:safe_malloc_
Line
Count
Source
89
1.01M
{
90
1.01M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.01M
  if(alloc_check())
93
217
    return NULL;
94
1.01M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.01M
  if(!size)
97
0
    size++;
98
1.01M
  return malloc(size);
99
1.01M
}
100
101
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
102
static inline void *malloc_(size_t size)
103
146k
{
104
  /* Fail if requested */
105
146k
  if(alloc_check())
106
9
    return NULL;
107
146k
  return malloc(size);
108
146k
}
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
146k
{
104
  /* Fail if requested */
105
146k
  if(alloc_check())
106
9
    return NULL;
107
146k
  return malloc(size);
108
146k
}
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_
109
#else
110
#define malloc_ malloc
111
#endif
112
113
114
115
static inline void *safe_calloc_(size_t nmemb, size_t size)
116
280k
{
117
280k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
280k
  if(alloc_check())
120
770
    return NULL;
121
279k
#endif
122
279k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
279k
  return calloc(nmemb, size);
125
279k
}
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
11.2k
{
117
11.2k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
11.2k
  if(alloc_check())
120
101
    return NULL;
121
11.1k
#endif
122
11.1k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
11.1k
  return calloc(nmemb, size);
125
11.1k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
138k
{
117
138k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
138k
  if(alloc_check())
120
480
    return NULL;
121
137k
#endif
122
137k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
137k
  return calloc(nmemb, size);
125
137k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
131k
{
117
131k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
131k
  if(alloc_check())
120
189
    return NULL;
121
131k
#endif
122
131k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
131k
  return calloc(nmemb, size);
125
131k
}
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_
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
1.03M
{
131
1.03M
  size2 += size1;
132
1.03M
  if(size2 < size1)
133
0
    return 0;
134
1.03M
  return safe_malloc_(size2);
135
1.03M
}
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_
Unexecuted instantiation: iconvert.c:safe_malloc_add_2op_
picture.c:safe_malloc_add_2op_
Line
Count
Source
130
3.91k
{
131
3.91k
  size2 += size1;
132
3.91k
  if(size2 < size1)
133
0
    return 0;
134
3.91k
  return safe_malloc_(size2);
135
3.91k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_add_2op_
Unexecuted instantiation: format.c:safe_malloc_add_2op_
Unexecuted instantiation: metadata_iterators.c:safe_malloc_add_2op_
metadata_object.c:safe_malloc_add_2op_
Line
Count
Source
130
7.51k
{
131
7.51k
  size2 += size1;
132
7.51k
  if(size2 < size1)
133
0
    return 0;
134
7.51k
  return safe_malloc_(size2);
135
7.51k
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
16.5k
{
131
16.5k
  size2 += size1;
132
16.5k
  if(size2 < size1)
133
0
    return 0;
134
16.5k
  return safe_malloc_(size2);
135
16.5k
}
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
1.01M
{
131
1.01M
  size2 += size1;
132
1.01M
  if(size2 < size1)
133
0
    return 0;
134
1.01M
  return safe_malloc_(size2);
135
1.01M
}
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_
147
148
static inline void *safe_malloc_add_4op_(size_t size1, size_t size2, size_t size3, size_t size4)
149
419
{
150
419
  size2 += size1;
151
419
  if(size2 < size1)
152
0
    return 0;
153
419
  size3 += size2;
154
419
  if(size3 < size2)
155
0
    return 0;
156
419
  size4 += size3;
157
419
  if(size4 < size3)
158
0
    return 0;
159
419
  return safe_malloc_(size4);
160
419
}
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
419
{
150
419
  size2 += size1;
151
419
  if(size2 < size1)
152
0
    return 0;
153
419
  size3 += size2;
154
419
  if(size3 < size2)
155
0
    return 0;
156
419
  size4 += size3;
157
419
  if(size4 < size3)
158
0
    return 0;
159
419
  return safe_malloc_(size4);
160
419
}
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_
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_
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_
185
186
/* size1 * (size2 + size3) */
187
static inline void *safe_malloc_muladd2_(size_t size1, size_t size2, size_t size3)
188
146k
{
189
146k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
146k
  size2 += size3;
192
146k
  if(size2 < size3)
193
0
    return 0;
194
146k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
146k
  return malloc_(size1*size2);
197
146k
}
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
146k
{
189
146k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
146k
  size2 += size3;
192
146k
  if(size2 < size3)
193
0
    return 0;
194
146k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
146k
  return malloc_(size1*size2);
197
146k
}
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_
198
199
static inline void *safe_realloc_(void *ptr, size_t size)
200
1.17M
{
201
1.17M
  void *oldptr;
202
1.17M
  void *newptr;
203
1.17M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.17M
  if(alloc_check() && size > 0) {
206
96
    free(ptr);
207
96
    return NULL;
208
96
  }
209
1.17M
#endif
210
1.17M
  oldptr = ptr;
211
1.17M
  newptr = realloc(ptr, size);
212
1.17M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.17M
  return newptr;
215
1.17M
}
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
5.56k
{
201
5.56k
  void *oldptr;
202
5.56k
  void *newptr;
203
5.56k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
5.56k
  if(alloc_check() && size > 0) {
206
3
    free(ptr);
207
3
    return NULL;
208
3
  }
209
5.56k
#endif
210
5.56k
  oldptr = ptr;
211
5.56k
  newptr = realloc(ptr, size);
212
5.56k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
5.56k
  return newptr;
215
5.56k
}
format.c:safe_realloc_
Line
Count
Source
200
1.15M
{
201
1.15M
  void *oldptr;
202
1.15M
  void *newptr;
203
1.15M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.15M
  if(alloc_check() && size > 0) {
206
79
    free(ptr);
207
79
    return NULL;
208
79
  }
209
1.15M
#endif
210
1.15M
  oldptr = ptr;
211
1.15M
  newptr = realloc(ptr, size);
212
1.15M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.15M
  return newptr;
215
1.15M
}
Unexecuted instantiation: metadata_iterators.c:safe_realloc_
Unexecuted instantiation: metadata_object.c:safe_realloc_
stream_decoder.c:safe_realloc_
Line
Count
Source
200
6.65k
{
201
6.65k
  void *oldptr;
202
6.65k
  void *newptr;
203
6.65k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
6.65k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
6.64k
#endif
210
6.64k
  oldptr = ptr;
211
6.64k
  newptr = realloc(ptr, size);
212
6.64k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
6.64k
  return newptr;
215
6.65k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_
ogg_decoder_aspect.c:safe_realloc_
Line
Count
Source
200
1.53k
{
201
1.53k
  void *oldptr;
202
1.53k
  void *newptr;
203
1.53k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.53k
  if(alloc_check() && size > 0) {
206
4
    free(ptr);
207
4
    return NULL;
208
4
  }
209
1.52k
#endif
210
1.52k
  oldptr = ptr;
211
1.52k
  newptr = realloc(ptr, size);
212
1.52k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.52k
  return newptr;
215
1.53k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
9.02k
{
201
9.02k
  void *oldptr;
202
9.02k
  void *newptr;
203
9.02k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
9.02k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
9.01k
#endif
210
9.01k
  oldptr = ptr;
211
9.01k
  newptr = realloc(ptr, size);
212
9.01k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
9.01k
  return newptr;
215
9.02k
}
Unexecuted instantiation: memory.c:safe_realloc_
216
217
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
218
static inline void *realloc_(void *ptr, size_t size)
219
322k
{
220
  /* Fail if requested */
221
322k
  if(alloc_check())
222
247
    return NULL;
223
322k
  return realloc(ptr, size);
224
322k
}
encode.c:realloc_
Line
Count
Source
219
201k
{
220
  /* Fail if requested */
221
201k
  if(alloc_check())
222
33
    return NULL;
223
201k
  return realloc(ptr, size);
224
201k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
83.9k
{
220
  /* Fail if requested */
221
83.9k
  if(alloc_check())
222
13
    return NULL;
223
83.9k
  return realloc(ptr, size);
224
83.9k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
1.92k
{
220
  /* Fail if requested */
221
1.92k
  if(alloc_check())
222
159
    return NULL;
223
1.76k
  return realloc(ptr, size);
224
1.92k
}
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
292
{
220
  /* Fail if requested */
221
292
  if(alloc_check())
222
6
    return NULL;
223
286
  return realloc(ptr, size);
224
292
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
5.64k
{
220
  /* Fail if requested */
221
5.64k
  if(alloc_check())
222
6
    return NULL;
223
5.64k
  return realloc(ptr, size);
224
5.64k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
29.0k
{
220
  /* Fail if requested */
221
29.0k
  if(alloc_check())
222
30
    return NULL;
223
28.9k
  return realloc(ptr, size);
224
29.0k
}
Unexecuted instantiation: md5.c:realloc_
Unexecuted instantiation: memory.c:realloc_
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
2.21k
{
232
2.21k
  size2 += size1;
233
2.21k
  if(size2 < size1)
234
0
    return 0;
235
2.21k
  return realloc_(ptr, size2);
236
2.21k
}
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
1.92k
{
232
1.92k
  size2 += size1;
233
1.92k
  if(size2 < size1)
234
0
    return 0;
235
1.92k
  return realloc_(ptr, size2);
236
1.92k
}
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
292
{
232
292
  size2 += size1;
233
292
  if(size2 < size1)
234
0
    return 0;
235
292
  return realloc_(ptr, size2);
236
292
}
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_
237
238
static inline void *safe_realloc_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
239
0
{
240
0
  size2 += size1;
241
0
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
0
  size3 += size2;
246
0
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
0
  return safe_realloc_(ptr, size3);
251
0
}
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_
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_
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_
277
278
static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
279
8.18k
{
280
8.18k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
8.18k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
8.18k
  return safe_realloc_(ptr, size1*size2);
287
8.18k
}
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
6.65k
{
280
6.65k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
6.65k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
6.65k
  return safe_realloc_(ptr, size1*size2);
287
6.65k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_mul_2op_
ogg_decoder_aspect.c:safe_realloc_mul_2op_
Line
Count
Source
279
1.53k
{
280
1.53k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
1.53k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
1.53k
  return safe_realloc_(ptr, size1*size2);
287
1.53k
}
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_
288
289
static inline void *safe_realloc_nofree_mul_2op_(void *ptr, size_t size1, size_t size2)
290
320k
{
291
320k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
320k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
320k
  return realloc_(ptr, size1*size2);
296
320k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
201k
{
291
201k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
201k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
201k
  return realloc_(ptr, size1*size2);
296
201k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
83.9k
{
291
83.9k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
83.9k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
83.9k
  return realloc_(ptr, size1*size2);
296
83.9k
}
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
5.64k
{
291
5.64k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
5.64k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
5.64k
  return realloc_(ptr, size1*size2);
296
5.64k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
29.0k
{
291
29.0k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
29.0k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
29.0k
  return realloc_(ptr, size1*size2);
296
29.0k
}
Unexecuted instantiation: md5.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_mul_2op_
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_
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
285k
{
314
285k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
285k
  size2 += size3;
317
285k
  if(size2 < size3)
318
0
    return 0;
319
285k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
285k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
201k
{
314
201k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
201k
  size2 += size3;
317
201k
  if(size2 < size3)
318
0
    return 0;
319
201k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
201k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
83.9k
{
314
83.9k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
83.9k
  size2 += size3;
317
83.9k
  if(size2 < size3)
318
0
    return 0;
319
83.9k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
83.9k
}
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_
321
322
#endif