Coverage Report

Created: 2026-05-16 06:50

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
12.1M
static inline int alloc_check(void) {
71
12.1M
  if(alloc_check_threshold == INT32_MAX)
72
10.0M
    return 0;
73
2.15M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
1.65k
    return 1;
75
2.15M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.33k
    return 1;
77
2.14M
  else {
78
2.14M
    return 0;
79
2.14M
  }
80
12.1M
}
encode.c:alloc_check
Line
Count
Source
70
148k
static inline int alloc_check(void) {
71
148k
  if(alloc_check_threshold == INT32_MAX)
72
129k
    return 0;
73
19.9k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
49
    return 1;
75
19.8k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
19.8k
  else {
78
19.8k
    return 0;
79
19.8k
  }
80
148k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
69.4k
static inline int alloc_check(void) {
71
69.4k
  if(alloc_check_threshold == INT32_MAX)
72
68.2k
    return 0;
73
1.15k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
13
    return 1;
75
1.14k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
1.14k
  else {
78
1.14k
    return 0;
79
1.14k
  }
80
69.4k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
36.3k
static inline int alloc_check(void) {
71
36.3k
  if(alloc_check_threshold == INT32_MAX)
72
35.2k
    return 0;
73
1.18k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
23
    return 1;
75
1.15k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
147
    return 1;
77
1.01k
  else {
78
1.01k
    return 0;
79
1.01k
  }
80
36.3k
}
picture.c:alloc_check
Line
Count
Source
70
6.79k
static inline int alloc_check(void) {
71
6.79k
  if(alloc_check_threshold == INT32_MAX)
72
4.21k
    return 0;
73
2.58k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
37
    return 1;
75
2.54k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
338
    return 1;
77
2.21k
  else {
78
2.21k
    return 0;
79
2.21k
  }
80
6.79k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
45.9k
static inline int alloc_check(void) {
71
45.9k
  if(alloc_check_threshold == INT32_MAX)
72
43.2k
    return 0;
73
2.73k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
5
    return 1;
75
2.72k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
2.72k
  else {
78
2.72k
    return 0;
79
2.72k
  }
80
45.9k
}
format.c:alloc_check
Line
Count
Source
70
3.83M
static inline int alloc_check(void) {
71
3.83M
  if(alloc_check_threshold == INT32_MAX)
72
2.94M
    return 0;
73
891k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
237
    return 1;
75
891k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
891k
  else {
78
891k
    return 0;
79
891k
  }
80
3.83M
}
metadata_iterators.c:alloc_check
Line
Count
Source
70
974k
static inline int alloc_check(void) {
71
974k
  if(alloc_check_threshold == INT32_MAX)
72
974k
    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
974k
}
metadata_object.c:alloc_check
Line
Count
Source
70
1.49M
static inline int alloc_check(void) {
71
1.49M
  if(alloc_check_threshold == INT32_MAX)
72
1.47M
    return 0;
73
19.6k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
136
    return 1;
75
19.4k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
539
    return 1;
77
18.9k
  else {
78
18.9k
    return 0;
79
18.9k
  }
80
1.49M
}
stream_decoder.c:alloc_check
Line
Count
Source
70
1.62M
static inline int alloc_check(void) {
71
1.62M
  if(alloc_check_threshold == INT32_MAX)
72
1.38M
    return 0;
73
240k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
413
    return 1;
75
240k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
201
    return 1;
77
240k
  else {
78
240k
    return 0;
79
240k
  }
80
1.62M
}
stream_encoder.c:alloc_check
Line
Count
Source
70
365k
static inline int alloc_check(void) {
71
365k
  if(alloc_check_threshold == INT32_MAX)
72
276k
    return 0;
73
89.0k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
73
    return 1;
75
89.0k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
103
    return 1;
77
88.9k
  else {
78
88.9k
    return 0;
79
88.9k
  }
80
365k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
96.0k
static inline int alloc_check(void) {
71
96.0k
  if(alloc_check_threshold == INT32_MAX)
72
69.4k
    return 0;
73
26.6k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
59
    return 1;
75
26.5k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
26.5k
  else {
78
26.5k
    return 0;
79
26.5k
  }
80
96.0k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
5.51k
static inline int alloc_check(void) {
71
5.51k
  if(alloc_check_threshold == INT32_MAX)
72
4.60k
    return 0;
73
912
  else if(alloc_check_counter++ == alloc_check_threshold)
74
41
    return 1;
75
871
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
871
  else {
78
871
    return 0;
79
871
  }
80
5.51k
}
bitwriter.c:alloc_check
Line
Count
Source
70
50.3k
static inline int alloc_check(void) {
71
50.3k
  if(alloc_check_threshold == INT32_MAX)
72
47.1k
    return 0;
73
3.20k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
62
    return 1;
75
3.14k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
3.14k
  else {
78
3.14k
    return 0;
79
3.14k
  }
80
50.3k
}
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.1k
    return 0;
73
7.00k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
219
    return 1;
75
6.78k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
4
    return 1;
77
6.78k
  else {
78
6.78k
    return 0;
79
6.78k
  }
80
41.1k
}
memory.c:alloc_check
Line
Count
Source
70
3.29M
static inline int alloc_check(void) {
71
3.29M
  if(alloc_check_threshold == INT32_MAX)
72
2.44M
    return 0;
73
846k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
286
    return 1;
75
846k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
846k
  else {
78
846k
    return 0;
79
846k
  }
80
3.29M
}
operations.c:alloc_check
Line
Count
Source
70
4.86k
static inline int alloc_check(void) {
71
4.86k
  if(alloc_check_threshold == INT32_MAX)
72
4.86k
    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.86k
}
options.c:alloc_check
Line
Count
Source
70
6
static inline int alloc_check(void) {
71
6
  if(alloc_check_threshold == INT32_MAX)
72
6
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
6
}
utils.c:alloc_check
Line
Count
Source
70
47.2k
static inline int alloc_check(void) {
71
47.2k
  if(alloc_check_threshold == INT32_MAX)
72
47.2k
    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
47.2k
}
Unexecuted instantiation: alloc.c:alloc_check
metadata.cpp:alloc_check()
Line
Count
Source
70
9.06k
static inline int alloc_check(void) {
71
9.06k
  if(alloc_check_threshold == INT32_MAX)
72
9.06k
    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
9.06k
}
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
6.37M
{
90
6.37M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
6.37M
  if(alloc_check())
93
1.28k
    return NULL;
94
6.37M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
6.37M
  if(!size)
97
5.79k
    size++;
98
6.37M
  return malloc(size);
99
6.37M
}
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
163
{
90
163
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
163
  if(alloc_check())
93
0
    return NULL;
94
163
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
163
  if(!size)
97
0
    size++;
98
163
  return malloc(size);
99
163
}
picture.c:safe_malloc_
Line
Count
Source
89
6.79k
{
90
6.79k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
6.79k
  if(alloc_check())
93
375
    return NULL;
94
6.42k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
6.42k
  if(!size)
97
0
    size++;
98
6.42k
  return malloc(size);
99
6.79k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_
Unexecuted instantiation: format.c:safe_malloc_
metadata_iterators.c:safe_malloc_
Line
Count
Source
89
974k
{
90
974k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
974k
  if(alloc_check())
93
0
    return NULL;
94
974k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
974k
  if(!size)
97
0
    size++;
98
974k
  return malloc(size);
99
974k
}
metadata_object.c:safe_malloc_
Line
Count
Source
89
1.40M
{
90
1.40M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.40M
  if(alloc_check())
93
562
    return NULL;
94
1.40M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.40M
  if(!size)
97
0
    size++;
98
1.40M
  return malloc(size);
99
1.40M
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
674k
{
90
674k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
674k
  if(alloc_check())
93
16
    return NULL;
94
674k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
674k
  if(!size)
97
5.79k
    size++;
98
674k
  return malloc(size);
99
674k
}
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.51k
{
90
5.51k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.51k
  if(alloc_check())
93
41
    return NULL;
94
5.47k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.47k
  if(!size)
97
0
    size++;
98
5.47k
  return malloc(size);
99
5.51k
}
Unexecuted instantiation: bitwriter.c:safe_malloc_
md5.c:safe_malloc_
Line
Count
Source
89
219
{
90
219
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
219
  if(alloc_check())
93
4
    return NULL;
94
215
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
215
  if(!size)
97
0
    size++;
98
215
  return malloc(size);
99
219
}
memory.c:safe_malloc_
Line
Count
Source
89
3.29M
{
90
3.29M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.29M
  if(alloc_check())
93
286
    return NULL;
94
3.29M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.29M
  if(!size)
97
0
    size++;
98
3.29M
  return malloc(size);
99
3.29M
}
operations.c:safe_malloc_
Line
Count
Source
89
4.86k
{
90
4.86k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
4.86k
  if(alloc_check())
93
0
    return NULL;
94
4.86k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
4.86k
  if(!size)
97
0
    size++;
98
4.86k
  return malloc(size);
99
4.86k
}
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
9.06k
{
90
9.06k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
9.06k
  if(alloc_check())
93
0
    return NULL;
94
9.06k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
9.06k
  if(!size)
97
0
    size++;
98
9.06k
  return malloc(size);
99
9.06k
}
100
101
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
102
static inline void *malloc_(size_t size)
103
403k
{
104
  /* Fail if requested */
105
403k
  if(alloc_check())
106
65
    return NULL;
107
403k
  return malloc(size);
108
403k
}
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
403k
{
104
  /* Fail if requested */
105
403k
  if(alloc_check())
106
65
    return NULL;
107
403k
  return malloc(size);
108
403k
}
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
981k
{
117
981k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
981k
  if(alloc_check())
120
803
    return NULL;
121
980k
#endif
122
980k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
980k
  return calloc(nmemb, size);
125
980k
}
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
85.1k
{
117
85.1k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
85.1k
  if(alloc_check())
120
105
    return NULL;
121
85.0k
#endif
122
85.0k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
85.0k
  return calloc(nmemb, size);
125
85.0k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
530k
{
117
530k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
530k
  if(alloc_check())
120
522
    return NULL;
121
530k
#endif
122
530k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
530k
  return calloc(nmemb, size);
125
530k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
365k
{
117
365k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
365k
  if(alloc_check())
120
176
    return NULL;
121
365k
#endif
122
365k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
365k
  return calloc(nmemb, size);
125
365k
}
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
6.20M
{
131
6.20M
  size2 += size1;
132
6.20M
  if(size2 < size1)
133
0
    return 0;
134
6.20M
  return safe_malloc_(size2);
135
6.20M
}
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
163
{
131
163
  size2 += size1;
132
163
  if(size2 < size1)
133
0
    return 0;
134
163
  return safe_malloc_(size2);
135
163
}
picture.c:safe_malloc_add_2op_
Line
Count
Source
130
5.81k
{
131
5.81k
  size2 += size1;
132
5.81k
  if(size2 < size1)
133
0
    return 0;
134
5.81k
  return safe_malloc_(size2);
135
5.81k
}
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
971k
{
131
971k
  size2 += size1;
132
971k
  if(size2 < size1)
133
0
    return 0;
134
971k
  return safe_malloc_(size2);
135
971k
}
metadata_object.c:safe_malloc_add_2op_
Line
Count
Source
130
1.26M
{
131
1.26M
  size2 += size1;
132
1.26M
  if(size2 < size1)
133
0
    return 0;
134
1.26M
  return safe_malloc_(size2);
135
1.26M
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
655k
{
131
655k
  size2 += size1;
132
655k
  if(size2 < size1)
133
0
    return 0;
134
655k
  return safe_malloc_(size2);
135
655k
}
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.29M
{
131
3.29M
  size2 += size1;
132
3.29M
  if(size2 < size1)
133
0
    return 0;
134
3.29M
  return safe_malloc_(size2);
135
3.29M
}
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
9.06k
{
131
9.06k
  size2 += size1;
132
9.06k
  if(size2 < size1)
133
0
    return 0;
134
9.06k
  return safe_malloc_(size2);
135
9.06k
}
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.23k
{
150
8.23k
  size2 += size1;
151
8.23k
  if(size2 < size1)
152
0
    return 0;
153
8.23k
  size3 += size2;
154
8.23k
  if(size3 < size2)
155
0
    return 0;
156
8.23k
  size4 += size3;
157
8.23k
  if(size4 < size3)
158
0
    return 0;
159
8.23k
  return safe_malloc_(size4);
160
8.23k
}
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.23k
{
150
8.23k
  size2 += size1;
151
8.23k
  if(size2 < size1)
152
0
    return 0;
153
8.23k
  size3 += size2;
154
8.23k
  if(size3 < size2)
155
0
    return 0;
156
8.23k
  size4 += size3;
157
8.23k
  if(size4 < size3)
158
0
    return 0;
159
8.23k
  return safe_malloc_(size4);
160
8.23k
}
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
403k
{
189
403k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
403k
  size2 += size3;
192
403k
  if(size2 < size3)
193
0
    return 0;
194
403k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
403k
  return malloc_(size1*size2);
197
403k
}
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
403k
{
189
403k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
403k
  size2 += size3;
192
403k
  if(size2 < size3)
193
0
    return 0;
194
403k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
403k
  return malloc_(size1*size2);
197
403k
}
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.00M
{
201
4.00M
  void *oldptr;
202
4.00M
  void *newptr;
203
4.00M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
4.00M
  if(alloc_check() && size > 0) {
206
478
    free(ptr);
207
478
    return NULL;
208
478
  }
209
4.00M
#endif
210
4.00M
  oldptr = ptr;
211
4.00M
  newptr = realloc(ptr, size);
212
4.00M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
4.00M
  return newptr;
215
4.00M
}
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
45.9k
{
201
45.9k
  void *oldptr;
202
45.9k
  void *newptr;
203
45.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
45.9k
  if(alloc_check() && size > 0) {
206
6
    free(ptr);
207
6
    return NULL;
208
6
  }
209
45.9k
#endif
210
45.9k
  oldptr = ptr;
211
45.9k
  newptr = realloc(ptr, size);
212
45.9k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
45.9k
  return newptr;
215
45.9k
}
format.c:safe_realloc_
Line
Count
Source
200
3.83M
{
201
3.83M
  void *oldptr;
202
3.83M
  void *newptr;
203
3.83M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
3.83M
  if(alloc_check() && size > 0) {
206
237
    free(ptr);
207
237
    return NULL;
208
237
  }
209
3.83M
#endif
210
3.83M
  oldptr = ptr;
211
3.83M
  newptr = realloc(ptr, size);
212
3.83M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
3.83M
  return newptr;
215
3.83M
}
Unexecuted instantiation: metadata_iterators.c:safe_realloc_
Unexecuted instantiation: metadata_object.c:safe_realloc_
stream_decoder.c:safe_realloc_
Line
Count
Source
200
17.7k
{
201
17.7k
  void *oldptr;
202
17.7k
  void *newptr;
203
17.7k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
17.7k
  if(alloc_check() && size > 0) {
206
11
    free(ptr);
207
11
    return NULL;
208
11
  }
209
17.7k
#endif
210
17.7k
  oldptr = ptr;
211
17.7k
  newptr = realloc(ptr, size);
212
17.7k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
17.7k
  return newptr;
215
17.7k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_
ogg_decoder_aspect.c:safe_realloc_
Line
Count
Source
200
11.8k
{
201
11.8k
  void *oldptr;
202
11.8k
  void *newptr;
203
11.8k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
11.8k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
11.8k
#endif
210
11.8k
  oldptr = ptr;
211
11.8k
  newptr = realloc(ptr, size);
212
11.8k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
11.8k
  return newptr;
215
11.8k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
40.9k
{
201
40.9k
  void *oldptr;
202
40.9k
  void *newptr;
203
40.9k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
40.9k
  if(alloc_check() && size > 0) {
206
219
    free(ptr);
207
219
    return NULL;
208
219
  }
209
40.7k
#endif
210
40.7k
  oldptr = ptr;
211
40.7k
  newptr = realloc(ptr, size);
212
40.7k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
40.7k
  return newptr;
215
40.9k
}
Unexecuted instantiation: memory.c:safe_realloc_
Unexecuted instantiation: operations.c:safe_realloc_
options.c:safe_realloc_
Line
Count
Source
200
6
{
201
6
  void *oldptr;
202
6
  void *newptr;
203
6
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
6
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
6
#endif
210
6
  oldptr = ptr;
211
6
  newptr = realloc(ptr, size);
212
6
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
6
  return newptr;
215
6
}
utils.c:safe_realloc_
Line
Count
Source
200
47.2k
{
201
47.2k
  void *oldptr;
202
47.2k
  void *newptr;
203
47.2k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
47.2k
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
47.2k
#endif
210
47.2k
  oldptr = ptr;
211
47.2k
  newptr = realloc(ptr, size);
212
47.2k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
47.2k
  return newptr;
215
47.2k
}
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
397k
{
220
  /* Fail if requested */
221
397k
  if(alloc_check())
222
357
    return NULL;
223
396k
  return realloc(ptr, size);
224
397k
}
encode.c:realloc_
Line
Count
Source
219
148k
{
220
  /* Fail if requested */
221
148k
  if(alloc_check())
222
50
    return NULL;
223
148k
  return realloc(ptr, size);
224
148k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
69.4k
{
220
  /* Fail if requested */
221
69.4k
  if(alloc_check())
222
13
    return NULL;
223
69.4k
  return realloc(ptr, size);
224
69.4k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
36.2k
{
220
  /* Fail if requested */
221
36.2k
  if(alloc_check())
222
170
    return NULL;
223
36.0k
  return realloc(ptr, size);
224
36.2k
}
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
7.82k
{
220
  /* Fail if requested */
221
7.82k
  if(alloc_check())
222
8
    return NULL;
223
7.81k
  return realloc(ptr, size);
224
7.82k
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
84.2k
{
220
  /* Fail if requested */
221
84.2k
  if(alloc_check())
222
54
    return NULL;
223
84.1k
  return realloc(ptr, size);
224
84.2k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
50.3k
{
220
  /* Fail if requested */
221
50.3k
  if(alloc_check())
222
62
    return NULL;
223
50.3k
  return realloc(ptr, size);
224
50.3k
}
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
44.0k
{
232
44.0k
  size2 += size1;
233
44.0k
  if(size2 < size1)
234
0
    return 0;
235
44.0k
  return realloc_(ptr, size2);
236
44.0k
}
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
36.2k
{
232
36.2k
  size2 += size1;
233
36.2k
  if(size2 < size1)
234
0
    return 0;
235
36.2k
  return realloc_(ptr, size2);
236
36.2k
}
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
7.82k
{
232
7.82k
  size2 += size1;
233
7.82k
  if(size2 < size1)
234
0
    return 0;
235
7.82k
  return realloc_(ptr, size2);
236
7.82k
}
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
47.2k
{
240
47.2k
  size2 += size1;
241
47.2k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
47.2k
  size3 += size2;
246
47.2k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
47.2k
  return safe_realloc_(ptr, size3);
251
47.2k
}
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
47.2k
{
240
47.2k
  size2 += size1;
241
47.2k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
47.2k
  size3 += size2;
246
47.2k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
47.2k
  return safe_realloc_(ptr, size3);
251
47.2k
}
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
29.5k
{
280
29.5k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
29.5k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
29.5k
  return safe_realloc_(ptr, size1*size2);
287
29.5k
}
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.7k
{
280
17.7k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
17.7k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
17.7k
  return safe_realloc_(ptr, size1*size2);
287
17.7k
}
Unexecuted instantiation: stream_encoder.c:safe_realloc_mul_2op_
ogg_decoder_aspect.c:safe_realloc_mul_2op_
Line
Count
Source
279
11.8k
{
280
11.8k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
11.8k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
11.8k
  return safe_realloc_(ptr, size1*size2);
287
11.8k
}
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
6
{
280
6
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
6
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
6
  return safe_realloc_(ptr, size1*size2);
287
6
}
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
352k
{
291
352k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
352k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
352k
  return realloc_(ptr, size1*size2);
296
352k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
148k
{
291
148k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
148k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
148k
  return realloc_(ptr, size1*size2);
296
148k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
69.4k
{
291
69.4k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
69.4k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
69.4k
  return realloc_(ptr, size1*size2);
296
69.4k
}
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
84.2k
{
291
84.2k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
84.2k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
84.2k
  return realloc_(ptr, size1*size2);
296
84.2k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
50.3k
{
291
50.3k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
50.3k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
50.3k
  return realloc_(ptr, size1*size2);
296
50.3k
}
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
218k
{
314
218k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
218k
  size2 += size3;
317
218k
  if(size2 < size3)
318
0
    return 0;
319
218k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
218k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
148k
{
314
148k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
148k
  size2 += size3;
317
148k
  if(size2 < size3)
318
0
    return 0;
319
148k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
148k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
69.4k
{
314
69.4k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
69.4k
  size2 += size3;
317
69.4k
  if(size2 < size3)
318
0
    return 0;
319
69.4k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
69.4k
}
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