Coverage Report

Created: 2025-08-29 06:55

/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
2.90M
static inline int alloc_check(void) {
71
2.90M
  if(alloc_check_threshold == INT32_MAX)
72
1.69M
    return 0;
73
1.21M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
899
    return 1;
75
1.21M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.05k
    return 1;
77
1.21M
  else {
78
1.21M
    return 0;
79
1.21M
  }
80
2.90M
}
encode.c:alloc_check
Line
Count
Source
70
231k
static inline int alloc_check(void) {
71
231k
  if(alloc_check_threshold == INT32_MAX)
72
214k
    return 0;
73
16.8k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
31
    return 1;
75
16.8k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
16.8k
  else {
78
16.8k
    return 0;
79
16.8k
  }
80
231k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
100k
static inline int alloc_check(void) {
71
100k
  if(alloc_check_threshold == INT32_MAX)
72
99.5k
    return 0;
73
1.13k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
11
    return 1;
75
1.12k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.12k
  else {
78
1.12k
    return 0;
79
1.12k
  }
80
100k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
1.86k
static inline int alloc_check(void) {
71
1.86k
  if(alloc_check_threshold == INT32_MAX)
72
831
    return 0;
73
1.03k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
11
    return 1;
75
1.02k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
148
    return 1;
77
875
  else {
78
875
    return 0;
79
875
  }
80
1.86k
}
picture.c:alloc_check
Line
Count
Source
70
4.24k
static inline int alloc_check(void) {
71
4.24k
  if(alloc_check_threshold == INT32_MAX)
72
2.69k
    return 0;
73
1.55k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
34
    return 1;
75
1.52k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
320
    return 1;
77
1.20k
  else {
78
1.20k
    return 0;
79
1.20k
  }
80
4.24k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
5.81k
static inline int alloc_check(void) {
71
5.81k
  if(alloc_check_threshold == INT32_MAX)
72
4.16k
    return 0;
73
1.64k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
1.64k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.64k
  else {
78
1.64k
    return 0;
79
1.64k
  }
80
5.81k
}
format.c:alloc_check
Line
Count
Source
70
1.08M
static inline int alloc_check(void) {
71
1.08M
  if(alloc_check_threshold == INT32_MAX)
72
548k
    return 0;
73
532k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
81
    return 1;
75
531k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
531k
  else {
78
531k
    return 0;
79
531k
  }
80
1.08M
}
Unexecuted instantiation: metadata_iterators.c:alloc_check
metadata_object.c:alloc_check
Line
Count
Source
70
55.5k
static inline int alloc_check(void) {
71
55.5k
  if(alloc_check_threshold == INT32_MAX)
72
49.3k
    return 0;
73
6.16k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
102
    return 1;
75
6.06k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
254
    return 1;
77
5.81k
  else {
78
5.81k
    return 0;
79
5.81k
  }
80
55.5k
}
stream_decoder.c:alloc_check
Line
Count
Source
70
301k
static inline int alloc_check(void) {
71
301k
  if(alloc_check_threshold == INT32_MAX)
72
178k
    return 0;
73
123k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
314
    return 1;
75
122k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
207
    return 1;
77
122k
  else {
78
122k
    return 0;
79
122k
  }
80
301k
}
stream_encoder.c:alloc_check
Line
Count
Source
70
126k
static inline int alloc_check(void) {
71
126k
  if(alloc_check_threshold == INT32_MAX)
72
93.3k
    return 0;
73
32.8k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
58
    return 1;
75
32.7k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
123
    return 1;
77
32.6k
  else {
78
32.6k
    return 0;
79
32.6k
  }
80
126k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
7.14k
static inline int alloc_check(void) {
71
7.14k
  if(alloc_check_threshold == INT32_MAX)
72
2.80k
    return 0;
73
4.33k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
10
    return 1;
75
4.32k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
4.32k
  else {
78
4.32k
    return 0;
79
4.32k
  }
80
7.14k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
861
static inline int alloc_check(void) {
71
861
  if(alloc_check_threshold == INT32_MAX)
72
726
    return 0;
73
135
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
132
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
132
  else {
78
132
    return 0;
79
132
  }
80
861
}
bitwriter.c:alloc_check
Line
Count
Source
70
27.4k
static inline int alloc_check(void) {
71
27.4k
  if(alloc_check_threshold == INT32_MAX)
72
26.2k
    return 0;
73
1.12k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
30
    return 1;
75
1.09k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.09k
  else {
78
1.09k
    return 0;
79
1.09k
  }
80
27.4k
}
md5.c:alloc_check
Line
Count
Source
70
8.85k
static inline int alloc_check(void) {
71
8.85k
  if(alloc_check_threshold == INT32_MAX)
72
7.69k
    return 0;
73
1.16k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
6
    return 1;
75
1.15k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
4
    return 1;
77
1.15k
  else {
78
1.15k
    return 0;
79
1.15k
  }
80
8.85k
}
memory.c:alloc_check
Line
Count
Source
70
956k
static inline int alloc_check(void) {
71
956k
  if(alloc_check_threshold == INT32_MAX)
72
464k
    return 0;
73
492k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
205
    return 1;
75
492k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
492k
  else {
78
492k
    return 0;
79
492k
  }
80
956k
}
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.02M
{
90
1.02M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.02M
  if(alloc_check())
93
834
    return NULL;
94
1.02M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.02M
  if(!size)
97
36
    size++;
98
1.02M
  return malloc(size);
99
1.02M
}
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.24k
{
90
4.24k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
4.24k
  if(alloc_check())
93
354
    return NULL;
94
3.89k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.89k
  if(!size)
97
0
    size++;
98
3.89k
  return malloc(size);
99
4.24k
}
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
44.6k
{
90
44.6k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
44.6k
  if(alloc_check())
93
261
    return NULL;
94
44.4k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
44.4k
  if(!size)
97
0
    size++;
98
44.4k
  return malloc(size);
99
44.6k
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
14.2k
{
90
14.2k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
14.2k
  if(alloc_check())
93
7
    return NULL;
94
14.2k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
14.2k
  if(!size)
97
36
    size++;
98
14.2k
  return malloc(size);
99
14.2k
}
Unexecuted instantiation: stream_encoder.c:safe_malloc_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_malloc_
ogg_helper.c:safe_malloc_
Line
Count
Source
89
861
{
90
861
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
861
  if(alloc_check())
93
3
    return NULL;
94
858
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
858
  if(!size)
97
0
    size++;
98
858
  return malloc(size);
99
861
}
Unexecuted instantiation: bitwriter.c:safe_malloc_
md5.c:safe_malloc_
Line
Count
Source
89
6
{
90
6
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
6
  if(alloc_check())
93
4
    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
6
}
memory.c:safe_malloc_
Line
Count
Source
89
956k
{
90
956k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
956k
  if(alloc_check())
93
205
    return NULL;
94
956k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
956k
  if(!size)
97
0
    size++;
98
956k
  return malloc(size);
99
956k
}
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
8
    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
8
    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
271k
{
117
271k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
271k
  if(alloc_check())
120
772
    return NULL;
121
270k
#endif
122
270k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
270k
  return calloc(nmemb, size);
125
270k
}
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
10.5k
{
117
10.5k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
10.5k
  if(alloc_check())
120
90
    return NULL;
121
10.4k
#endif
122
10.4k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
10.4k
  return calloc(nmemb, size);
125
10.4k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
134k
{
117
134k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
134k
  if(alloc_check())
120
501
    return NULL;
121
134k
#endif
122
134k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
134k
  return calloc(nmemb, size);
125
134k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
126k
{
117
126k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
126k
  if(alloc_check())
120
181
    return NULL;
121
125k
#endif
122
125k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
125k
  return calloc(nmemb, size);
125
125k
}
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
981k
{
131
981k
  size2 += size1;
132
981k
  if(size2 < size1)
133
0
    return 0;
134
981k
  return safe_malloc_(size2);
135
981k
}
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.62k
{
131
3.62k
  size2 += size1;
132
3.62k
  if(size2 < size1)
133
0
    return 0;
134
3.62k
  return safe_malloc_(size2);
135
3.62k
}
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
6.53k
{
131
6.53k
  size2 += size1;
132
6.53k
  if(size2 < size1)
133
0
    return 0;
134
6.53k
  return safe_malloc_(size2);
135
6.53k
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
14.0k
{
131
14.0k
  size2 += size1;
132
14.0k
  if(size2 < size1)
133
0
    return 0;
134
14.0k
  return safe_malloc_(size2);
135
14.0k
}
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
956k
{
131
956k
  size2 += size1;
132
956k
  if(size2 < size1)
133
0
    return 0;
134
956k
  return safe_malloc_(size2);
135
956k
}
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
400
{
150
400
  size2 += size1;
151
400
  if(size2 < size1)
152
0
    return 0;
153
400
  size3 += size2;
154
400
  if(size3 < size2)
155
0
    return 0;
156
400
  size4 += size3;
157
400
  if(size4 < size3)
158
0
    return 0;
159
400
  return safe_malloc_(size4);
160
400
}
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
400
{
150
400
  size2 += size1;
151
400
  if(size2 < size1)
152
0
    return 0;
153
400
  size3 += size2;
154
400
  if(size3 < size2)
155
0
    return 0;
156
400
  size4 += size3;
157
400
  if(size4 < size3)
158
0
    return 0;
159
400
  return safe_malloc_(size4);
160
400
}
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.10M
{
201
1.10M
  void *oldptr;
202
1.10M
  void *newptr;
203
1.10M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.10M
  if(alloc_check() && size > 0) {
206
100
    free(ptr);
207
100
    return NULL;
208
100
  }
209
1.10M
#endif
210
1.10M
  oldptr = ptr;
211
1.10M
  newptr = realloc(ptr, size);
212
1.10M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.10M
  return newptr;
215
1.10M
}
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.81k
{
201
5.81k
  void *oldptr;
202
5.81k
  void *newptr;
203
5.81k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
5.81k
  if(alloc_check() && size > 0) {
206
3
    free(ptr);
207
3
    return NULL;
208
3
  }
209
5.81k
#endif
210
5.81k
  oldptr = ptr;
211
5.81k
  newptr = realloc(ptr, size);
212
5.81k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
5.81k
  return newptr;
215
5.81k
}
format.c:safe_realloc_
Line
Count
Source
200
1.08M
{
201
1.08M
  void *oldptr;
202
1.08M
  void *newptr;
203
1.08M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.08M
  if(alloc_check() && size > 0) {
206
81
    free(ptr);
207
81
    return NULL;
208
81
  }
209
1.08M
#endif
210
1.08M
  oldptr = ptr;
211
1.08M
  newptr = realloc(ptr, size);
212
1.08M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.08M
  return newptr;
215
1.08M
}
Unexecuted instantiation: metadata_iterators.c:safe_realloc_
Unexecuted instantiation: metadata_object.c:safe_realloc_
stream_decoder.c:safe_realloc_
Line
Count
Source
200
6.14k
{
201
6.14k
  void *oldptr;
202
6.14k
  void *newptr;
203
6.14k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
6.14k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
6.14k
#endif
210
6.14k
  oldptr = ptr;
211
6.14k
  newptr = realloc(ptr, size);
212
6.14k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
6.14k
  return newptr;
215
6.14k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_
ogg_decoder_aspect.c:safe_realloc_
Line
Count
Source
200
1.47k
{
201
1.47k
  void *oldptr;
202
1.47k
  void *newptr;
203
1.47k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
1.47k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
1.47k
#endif
210
1.47k
  oldptr = ptr;
211
1.47k
  newptr = realloc(ptr, size);
212
1.47k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
1.47k
  return newptr;
215
1.47k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
8.85k
{
201
8.85k
  void *oldptr;
202
8.85k
  void *newptr;
203
8.85k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
8.85k
  if(alloc_check() && size > 0) {
206
6
    free(ptr);
207
6
    return NULL;
208
6
  }
209
8.84k
#endif
210
8.84k
  oldptr = ptr;
211
8.84k
  newptr = realloc(ptr, size);
212
8.84k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
8.84k
  return newptr;
215
8.85k
}
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
367k
{
220
  /* Fail if requested */
221
367k
  if(alloc_check())
222
243
    return NULL;
223
367k
  return realloc(ptr, size);
224
367k
}
encode.c:realloc_
Line
Count
Source
219
231k
{
220
  /* Fail if requested */
221
231k
  if(alloc_check())
222
32
    return NULL;
223
231k
  return realloc(ptr, size);
224
231k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
100k
{
220
  /* Fail if requested */
221
100k
  if(alloc_check())
222
12
    return NULL;
223
100k
  return realloc(ptr, size);
224
100k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
1.86k
{
220
  /* Fail if requested */
221
1.86k
  if(alloc_check())
222
159
    return NULL;
223
1.70k
  return realloc(ptr, size);
224
1.86k
}
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
273
{
220
  /* Fail if requested */
221
273
  if(alloc_check())
222
5
    return NULL;
223
268
  return realloc(ptr, size);
224
273
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
5.66k
{
220
  /* Fail if requested */
221
5.66k
  if(alloc_check())
222
5
    return NULL;
223
5.66k
  return realloc(ptr, size);
224
5.66k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
27.4k
{
220
  /* Fail if requested */
221
27.4k
  if(alloc_check())
222
30
    return NULL;
223
27.3k
  return realloc(ptr, size);
224
27.4k
}
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.13k
{
232
2.13k
  size2 += size1;
233
2.13k
  if(size2 < size1)
234
0
    return 0;
235
2.13k
  return realloc_(ptr, size2);
236
2.13k
}
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.86k
{
232
1.86k
  size2 += size1;
233
1.86k
  if(size2 < size1)
234
0
    return 0;
235
1.86k
  return realloc_(ptr, size2);
236
1.86k
}
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
273
{
232
273
  size2 += size1;
233
273
  if(size2 < size1)
234
0
    return 0;
235
273
  return realloc_(ptr, size2);
236
273
}
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
7.62k
{
280
7.62k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
7.62k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
7.62k
  return safe_realloc_(ptr, size1*size2);
287
7.62k
}
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.14k
{
280
6.14k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
6.14k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
6.14k
  return safe_realloc_(ptr, size1*size2);
287
6.14k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_mul_2op_
ogg_decoder_aspect.c:safe_realloc_mul_2op_
Line
Count
Source
279
1.47k
{
280
1.47k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
1.47k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
1.47k
  return safe_realloc_(ptr, size1*size2);
287
1.47k
}
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
365k
{
291
365k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
365k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
365k
  return realloc_(ptr, size1*size2);
296
365k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
231k
{
291
231k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
231k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
231k
  return realloc_(ptr, size1*size2);
296
231k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
100k
{
291
100k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
100k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
100k
  return realloc_(ptr, size1*size2);
296
100k
}
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.66k
{
291
5.66k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
5.66k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
5.66k
  return realloc_(ptr, size1*size2);
296
5.66k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
27.4k
{
291
27.4k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
27.4k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
27.4k
  return realloc_(ptr, size1*size2);
296
27.4k
}
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
332k
{
314
332k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
332k
  size2 += size3;
317
332k
  if(size2 < size3)
318
0
    return 0;
319
332k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
332k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
231k
{
314
231k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
231k
  size2 += size3;
317
231k
  if(size2 < size3)
318
0
    return 0;
319
231k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
231k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
100k
{
314
100k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
100k
  size2 += size3;
317
100k
  if(size2 < size3)
318
0
    return 0;
319
100k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
100k
}
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