Coverage Report

Created: 2026-10-31 06:16

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
36.2M
static inline int alloc_check(void) {
71
36.2M
  if(alloc_check_threshold == INT32_MAX)
72
33.8M
    return 0;
73
2.42M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
1.85k
    return 1;
75
2.41M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.59k
    return 1;
77
2.41M
  else {
78
2.41M
    return 0;
79
2.41M
  }
80
36.2M
}
encode.c:alloc_check
Line
Count
Source
70
188k
static inline int alloc_check(void) {
71
188k
  if(alloc_check_threshold == INT32_MAX)
72
168k
    return 0;
73
19.2k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
49
    return 1;
75
19.2k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
19.2k
  else {
78
19.2k
    return 0;
79
19.2k
  }
80
188k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
217k
static inline int alloc_check(void) {
71
217k
  if(alloc_check_threshold == INT32_MAX)
72
216k
    return 0;
73
1.03k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
13
    return 1;
75
1.02k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.02k
  else {
78
1.02k
    return 0;
79
1.02k
  }
80
217k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
76.6k
static inline int alloc_check(void) {
71
76.6k
  if(alloc_check_threshold == INT32_MAX)
72
75.4k
    return 0;
73
1.17k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
25
    return 1;
75
1.15k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
182
    return 1;
77
969
  else {
78
969
    return 0;
79
969
  }
80
76.6k
}
picture.c:alloc_check
Line
Count
Source
70
10.9k
static inline int alloc_check(void) {
71
10.9k
  if(alloc_check_threshold == INT32_MAX)
72
8.39k
    return 0;
73
2.52k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
35
    return 1;
75
2.49k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
327
    return 1;
77
2.16k
  else {
78
2.16k
    return 0;
79
2.16k
  }
80
10.9k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
49.8k
static inline int alloc_check(void) {
71
49.8k
  if(alloc_check_threshold == INT32_MAX)
72
48.3k
    return 0;
73
1.45k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
6
    return 1;
75
1.45k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.44k
  else {
78
1.44k
    return 0;
79
1.44k
  }
80
49.8k
}
format.c:alloc_check
Line
Count
Source
70
4.23M
static inline int alloc_check(void) {
71
4.23M
  if(alloc_check_threshold == INT32_MAX)
72
3.11M
    return 0;
73
1.12M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
245
    return 1;
75
1.12M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.12M
  else {
78
1.12M
    return 0;
79
1.12M
  }
80
4.23M
}
metadata_iterators.c:alloc_check
Line
Count
Source
70
21.8M
static inline int alloc_check(void) {
71
21.8M
  if(alloc_check_threshold == INT32_MAX)
72
21.8M
    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
21.8M
}
metadata_object.c:alloc_check
Line
Count
Source
70
4.00M
static inline int alloc_check(void) {
71
4.00M
  if(alloc_check_threshold == INT32_MAX)
72
3.98M
    return 0;
73
20.5k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
133
    return 1;
75
20.4k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
407
    return 1;
77
20.0k
  else {
78
20.0k
    return 0;
79
20.0k
  }
80
4.00M
}
stream_decoder.c:alloc_check
Line
Count
Source
70
1.48M
static inline int alloc_check(void) {
71
1.48M
  if(alloc_check_threshold == INT32_MAX)
72
1.29M
    return 0;
73
184k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
554
    return 1;
75
183k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
562
    return 1;
77
183k
  else {
78
183k
    return 0;
79
183k
  }
80
1.48M
}
stream_encoder.c:alloc_check
Line
Count
Source
70
386k
static inline int alloc_check(void) {
71
386k
  if(alloc_check_threshold == INT32_MAX)
72
290k
    return 0;
73
95.7k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
96
    return 1;
75
95.6k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
108
    return 1;
77
95.5k
  else {
78
95.5k
    return 0;
79
95.5k
  }
80
386k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
119k
static inline int alloc_check(void) {
71
119k
  if(alloc_check_threshold == INT32_MAX)
72
102k
    return 0;
73
16.4k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
62
    return 1;
75
16.3k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
16.3k
  else {
78
16.3k
    return 0;
79
16.3k
  }
80
119k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
5.82k
static inline int alloc_check(void) {
71
5.82k
  if(alloc_check_threshold == INT32_MAX)
72
4.69k
    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
5.82k
}
bitwriter.c:alloc_check
Line
Count
Source
70
43.8k
static inline int alloc_check(void) {
71
43.8k
  if(alloc_check_threshold == INT32_MAX)
72
41.3k
    return 0;
73
2.46k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
61
    return 1;
75
2.40k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
2.40k
  else {
78
2.40k
    return 0;
79
2.40k
  }
80
43.8k
}
md5.c:alloc_check
Line
Count
Source
70
41.1k
static inline int alloc_check(void) {
71
41.1k
  if(alloc_check_threshold == INT32_MAX)
72
34.4k
    return 0;
73
6.76k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
296
    return 1;
75
6.47k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
3
    return 1;
77
6.47k
  else {
78
6.47k
    return 0;
79
6.47k
  }
80
41.1k
}
memory.c:alloc_check
Line
Count
Source
70
3.52M
static inline int alloc_check(void) {
71
3.52M
  if(alloc_check_threshold == INT32_MAX)
72
2.58M
    return 0;
73
946k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
254
    return 1;
75
946k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
946k
  else {
78
946k
    return 0;
79
946k
  }
80
3.52M
}
operations.c:alloc_check
Line
Count
Source
70
5.38k
static inline int alloc_check(void) {
71
5.38k
  if(alloc_check_threshold == INT32_MAX)
72
5.38k
    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
5.38k
}
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
29.4k
static inline int alloc_check(void) {
71
29.4k
  if(alloc_check_threshold == INT32_MAX)
72
29.4k
    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
29.4k
}
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
29.8M
{
90
29.8M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
29.8M
  if(alloc_check())
93
1.04k
    return NULL;
94
29.8M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
29.8M
  if(!size)
97
6.38k
    size++;
98
29.8M
  return malloc(size);
99
29.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
767
{
90
767
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
767
  if(alloc_check())
93
0
    return NULL;
94
767
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
767
  if(!size)
97
0
    size++;
98
767
  return malloc(size);
99
767
}
picture.c:safe_malloc_
Line
Count
Source
89
10.9k
{
90
10.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
10.9k
  if(alloc_check())
93
362
    return NULL;
94
10.5k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
10.5k
  if(!size)
97
0
    size++;
98
10.5k
  return malloc(size);
99
10.9k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_
Unexecuted instantiation: format.c:safe_malloc_
metadata_iterators.c:safe_malloc_
Line
Count
Source
89
21.8M
{
90
21.8M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
21.8M
  if(alloc_check())
93
0
    return NULL;
94
21.8M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
21.8M
  if(!size)
97
0
    size++;
98
21.8M
  return malloc(size);
99
21.8M
}
metadata_object.c:safe_malloc_
Line
Count
Source
89
3.92M
{
90
3.92M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.92M
  if(alloc_check())
93
375
    return NULL;
94
3.92M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.92M
  if(!size)
97
0
    size++;
98
3.92M
  return malloc(size);
99
3.92M
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
567k
{
90
567k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
567k
  if(alloc_check())
93
18
    return NULL;
94
567k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
567k
  if(!size)
97
6.38k
    size++;
98
567k
  return malloc(size);
99
567k
}
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.82k
{
90
5.82k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.82k
  if(alloc_check())
93
30
    return NULL;
94
5.79k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.79k
  if(!size)
97
0
    size++;
98
5.79k
  return malloc(size);
99
5.82k
}
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.52M
{
90
3.52M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.52M
  if(alloc_check())
93
254
    return NULL;
94
3.52M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.52M
  if(!size)
97
0
    size++;
98
3.52M
  return malloc(size);
99
3.52M
}
operations.c:safe_malloc_
Line
Count
Source
89
5.38k
{
90
5.38k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.38k
  if(alloc_check())
93
0
    return NULL;
94
5.38k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.38k
  if(!size)
97
0
    size++;
98
5.38k
  return malloc(size);
99
5.38k
}
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
339k
{
104
  /* Fail if requested */
105
339k
  if(alloc_check())
106
97
    return NULL;
107
339k
  return malloc(size);
108
339k
}
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
339k
{
104
  /* Fail if requested */
105
339k
  if(alloc_check())
106
97
    return NULL;
107
339k
  return malloc(size);
108
339k
}
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.00M
{
117
1.00M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
1.00M
  if(alloc_check())
120
1.34k
    return NULL;
121
1.00M
#endif
122
1.00M
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
1.00M
  return calloc(nmemb, size);
125
1.00M
}
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
67.4k
{
117
67.4k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
67.4k
  if(alloc_check())
120
155
    return NULL;
121
67.3k
#endif
122
67.3k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
67.3k
  return calloc(nmemb, size);
125
67.3k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
555k
{
117
555k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
555k
  if(alloc_check())
120
988
    return NULL;
121
554k
#endif
122
554k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
554k
  return calloc(nmemb, size);
125
554k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
386k
{
117
386k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
386k
  if(alloc_check())
120
204
    return NULL;
121
386k
#endif
122
386k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
386k
  return calloc(nmemb, size);
125
386k
}
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
29.6M
{
131
29.6M
  size2 += size1;
132
29.6M
  if(size2 < size1)
133
0
    return 0;
134
29.6M
  return safe_malloc_(size2);
135
29.6M
}
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
767
{
131
767
  size2 += size1;
132
767
  if(size2 < size1)
133
0
    return 0;
134
767
  return safe_malloc_(size2);
135
767
}
picture.c:safe_malloc_add_2op_
Line
Count
Source
130
8.85k
{
131
8.85k
  size2 += size1;
132
8.85k
  if(size2 < size1)
133
0
    return 0;
134
8.85k
  return safe_malloc_(size2);
135
8.85k
}
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
21.8M
{
131
21.8M
  size2 += size1;
132
21.8M
  if(size2 < size1)
133
0
    return 0;
134
21.8M
  return safe_malloc_(size2);
135
21.8M
}
metadata_object.c:safe_malloc_add_2op_
Line
Count
Source
130
3.73M
{
131
3.73M
  size2 += size1;
132
3.73M
  if(size2 < size1)
133
0
    return 0;
134
3.73M
  return safe_malloc_(size2);
135
3.73M
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
549k
{
131
549k
  size2 += size1;
132
549k
  if(size2 < size1)
133
0
    return 0;
134
549k
  return safe_malloc_(size2);
135
549k
}
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.52M
{
131
3.52M
  size2 += size1;
132
3.52M
  if(size2 < size1)
133
0
    return 0;
134
3.52M
  return safe_malloc_(size2);
135
3.52M
}
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
8.77k
{
150
8.77k
  size2 += size1;
151
8.77k
  if(size2 < size1)
152
0
    return 0;
153
8.77k
  size3 += size2;
154
8.77k
  if(size3 < size2)
155
0
    return 0;
156
8.77k
  size4 += size3;
157
8.77k
  if(size4 < size3)
158
0
    return 0;
159
8.77k
  return safe_malloc_(size4);
160
8.77k
}
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
8.77k
{
150
8.77k
  size2 += size1;
151
8.77k
  if(size2 < size1)
152
0
    return 0;
153
8.77k
  size3 += size2;
154
8.77k
  if(size3 < size2)
155
0
    return 0;
156
8.77k
  size4 += size3;
157
8.77k
  if(size4 < size3)
158
0
    return 0;
159
8.77k
  return safe_malloc_(size4);
160
8.77k
}
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
339k
{
189
339k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
339k
  size2 += size3;
192
339k
  if(size2 < size3)
193
0
    return 0;
194
339k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
339k
  return malloc_(size1*size2);
197
339k
}
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
339k
{
189
339k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
339k
  size2 += size3;
192
339k
  if(size2 < size3)
193
0
    return 0;
194
339k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
339k
  return malloc_(size1*size2);
197
339k
}
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.38M
{
201
4.38M
  void *oldptr;
202
4.38M
  void *newptr;
203
4.38M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4.38M
  if(alloc_check() && size > 0) {
206
568
    free(ptr);
207
568
    return NULL;
208
568
  }
209
4.38M
#endif
210
4.38M
  oldptr = ptr;
211
4.38M
  newptr = realloc(ptr, size);
212
4.38M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4.38M
  return newptr;
215
4.38M
}
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.8k
{
201
49.8k
  void *oldptr;
202
49.8k
  void *newptr;
203
49.8k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
49.8k
  if(alloc_check() && size > 0) {
206
7
    free(ptr);
207
7
    return NULL;
208
7
  }
209
49.8k
#endif
210
49.8k
  oldptr = ptr;
211
49.8k
  newptr = realloc(ptr, size);
212
49.8k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
49.8k
  return newptr;
215
49.8k
}
format.c:safe_realloc_
Line
Count
Source
200
4.23M
{
201
4.23M
  void *oldptr;
202
4.23M
  void *newptr;
203
4.23M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4.23M
  if(alloc_check() && size > 0) {
206
245
    free(ptr);
207
245
    return NULL;
208
245
  }
209
4.23M
#endif
210
4.23M
  oldptr = ptr;
211
4.23M
  newptr = realloc(ptr, size);
212
4.23M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4.23M
  return newptr;
215
4.23M
}
Unexecuted instantiation: metadata_iterators.c:safe_realloc_
Unexecuted instantiation: metadata_object.c:safe_realloc_
stream_decoder.c:safe_realloc_
Line
Count
Source
200
17.4k
{
201
17.4k
  void *oldptr;
202
17.4k
  void *newptr;
203
17.4k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
17.4k
  if(alloc_check() && size > 0) {
206
13
    free(ptr);
207
13
    return NULL;
208
13
  }
209
17.4k
#endif
210
17.4k
  oldptr = ptr;
211
17.4k
  newptr = realloc(ptr, size);
212
17.4k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
17.4k
  return newptr;
215
17.4k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_
ogg_decoder_aspect.c:safe_realloc_
Line
Count
Source
200
12.9k
{
201
12.9k
  void *oldptr;
202
12.9k
  void *newptr;
203
12.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
12.9k
  if(alloc_check() && size > 0) {
206
7
    free(ptr);
207
7
    return NULL;
208
7
  }
209
12.9k
#endif
210
12.9k
  oldptr = ptr;
211
12.9k
  newptr = realloc(ptr, size);
212
12.9k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
12.9k
  return newptr;
215
12.9k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
40.8k
{
201
40.8k
  void *oldptr;
202
40.8k
  void *newptr;
203
40.8k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
40.8k
  if(alloc_check() && size > 0) {
206
296
    free(ptr);
207
296
    return NULL;
208
296
  }
209
40.5k
#endif
210
40.5k
  oldptr = ptr;
211
40.5k
  newptr = realloc(ptr, size);
212
40.5k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
40.5k
  return newptr;
215
40.8k
}
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
29.4k
{
201
29.4k
  void *oldptr;
202
29.4k
  void *newptr;
203
29.4k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
29.4k
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
29.4k
#endif
210
29.4k
  oldptr = ptr;
211
29.4k
  newptr = realloc(ptr, size);
212
29.4k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
29.4k
  return newptr;
215
29.4k
}
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
640k
{
220
  /* Fail if requested */
221
640k
  if(alloc_check())
222
398
    return NULL;
223
639k
  return realloc(ptr, size);
224
640k
}
encode.c:realloc_
Line
Count
Source
219
188k
{
220
  /* Fail if requested */
221
188k
  if(alloc_check())
222
50
    return NULL;
223
188k
  return realloc(ptr, size);
224
188k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
217k
{
220
  /* Fail if requested */
221
217k
  if(alloc_check())
222
14
    return NULL;
223
217k
  return realloc(ptr, size);
224
217k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
75.8k
{
220
  /* Fail if requested */
221
75.8k
  if(alloc_check())
222
207
    return NULL;
223
75.6k
  return realloc(ptr, size);
224
75.8k
}
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.53k
{
220
  /* Fail if requested */
221
8.53k
  if(alloc_check())
222
10
    return NULL;
223
8.52k
  return realloc(ptr, size);
224
8.53k
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
106k
{
220
  /* Fail if requested */
221
106k
  if(alloc_check())
222
56
    return NULL;
223
106k
  return realloc(ptr, size);
224
106k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
43.8k
{
220
  /* Fail if requested */
221
43.8k
  if(alloc_check())
222
61
    return NULL;
223
43.7k
  return realloc(ptr, size);
224
43.8k
}
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
84.3k
{
232
84.3k
  size2 += size1;
233
84.3k
  if(size2 < size1)
234
0
    return 0;
235
84.3k
  return realloc_(ptr, size2);
236
84.3k
}
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
75.8k
{
232
75.8k
  size2 += size1;
233
75.8k
  if(size2 < size1)
234
0
    return 0;
235
75.8k
  return realloc_(ptr, size2);
236
75.8k
}
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.53k
{
232
8.53k
  size2 += size1;
233
8.53k
  if(size2 < size1)
234
0
    return 0;
235
8.53k
  return realloc_(ptr, size2);
236
8.53k
}
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
29.4k
{
240
29.4k
  size2 += size1;
241
29.4k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
29.4k
  size3 += size2;
246
29.4k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
29.4k
  return safe_realloc_(ptr, size3);
251
29.4k
}
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
29.4k
{
240
29.4k
  size2 += size1;
241
29.4k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
29.4k
  size3 += size2;
246
29.4k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
29.4k
  return safe_realloc_(ptr, size3);
251
29.4k
}
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
30.4k
{
280
30.4k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
30.4k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
30.4k
  return safe_realloc_(ptr, size1*size2);
287
30.4k
}
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
17.4k
{
280
17.4k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
17.4k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
17.4k
  return safe_realloc_(ptr, size1*size2);
287
17.4k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_mul_2op_
ogg_decoder_aspect.c:safe_realloc_mul_2op_
Line
Count
Source
279
12.9k
{
280
12.9k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
12.9k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
12.9k
  return safe_realloc_(ptr, size1*size2);
287
12.9k
}
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
555k
{
291
555k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
555k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
555k
  return realloc_(ptr, size1*size2);
296
555k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
188k
{
291
188k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
188k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
188k
  return realloc_(ptr, size1*size2);
296
188k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
217k
{
291
217k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
217k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
217k
  return realloc_(ptr, size1*size2);
296
217k
}
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
106k
{
291
106k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
106k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
106k
  return realloc_(ptr, size1*size2);
296
106k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
43.8k
{
291
43.8k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
43.8k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
43.8k
  return realloc_(ptr, size1*size2);
296
43.8k
}
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
405k
{
314
405k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
405k
  size2 += size3;
317
405k
  if(size2 < size3)
318
0
    return 0;
319
405k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
405k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
188k
{
314
188k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
188k
  size2 += size3;
317
188k
  if(size2 < size3)
318
0
    return 0;
319
188k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
188k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
217k
{
314
217k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
217k
  size2 += size3;
317
217k
  if(size2 < size3)
318
0
    return 0;
319
217k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
217k
}
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