Coverage Report

Created: 2025-11-24 06:06

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.3M
static inline int alloc_check(void) {
71
12.3M
  if(alloc_check_threshold == INT32_MAX)
72
10.5M
    return 0;
73
1.87M
  else if(alloc_check_counter++ == alloc_check_threshold)
74
1.48k
    return 1;
75
1.87M
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1.06k
    return 1;
77
1.86M
  else {
78
1.86M
    return 0;
79
1.86M
  }
80
12.3M
}
encode.c:alloc_check
Line
Count
Source
70
176k
static inline int alloc_check(void) {
71
176k
  if(alloc_check_threshold == INT32_MAX)
72
159k
    return 0;
73
17.2k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
39
    return 1;
75
17.2k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
17.2k
  else {
78
17.2k
    return 0;
79
17.2k
  }
80
176k
}
foreign_metadata.c:alloc_check
Line
Count
Source
70
64.8k
static inline int alloc_check(void) {
71
64.8k
  if(alloc_check_threshold == INT32_MAX)
72
63.3k
    return 0;
73
1.49k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
13
    return 1;
75
1.48k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.48k
  else {
78
1.48k
    return 0;
79
1.48k
  }
80
64.8k
}
Unexecuted instantiation: tool_flac.c:alloc_check
Unexecuted instantiation: utf8.c:alloc_check
iconvert.c:alloc_check
Line
Count
Source
70
75.9k
static inline int alloc_check(void) {
71
75.9k
  if(alloc_check_threshold == INT32_MAX)
72
74.9k
    return 0;
73
1.04k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
17
    return 1;
75
1.02k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
150
    return 1;
77
876
  else {
78
876
    return 0;
79
876
  }
80
75.9k
}
picture.c:alloc_check
Line
Count
Source
70
9.49k
static inline int alloc_check(void) {
71
9.49k
  if(alloc_check_threshold == INT32_MAX)
72
7.70k
    return 0;
73
1.79k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
38
    return 1;
75
1.75k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
320
    return 1;
77
1.43k
  else {
78
1.43k
    return 0;
79
1.43k
  }
80
9.49k
}
replaygain_analysis.c:alloc_check
Line
Count
Source
70
52.0k
static inline int alloc_check(void) {
71
52.0k
  if(alloc_check_threshold == INT32_MAX)
72
50.3k
    return 0;
73
1.72k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
3
    return 1;
75
1.71k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
1
    return 1;
77
1.71k
  else {
78
1.71k
    return 0;
79
1.71k
  }
80
52.0k
}
format.c:alloc_check
Line
Count
Source
70
3.63M
static inline int alloc_check(void) {
71
3.63M
  if(alloc_check_threshold == INT32_MAX)
72
2.85M
    return 0;
73
782k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
178
    return 1;
75
782k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
782k
  else {
78
782k
    return 0;
79
782k
  }
80
3.63M
}
metadata_iterators.c:alloc_check
Line
Count
Source
70
1.47M
static inline int alloc_check(void) {
71
1.47M
  if(alloc_check_threshold == INT32_MAX)
72
1.47M
    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
1.47M
}
metadata_object.c:alloc_check
Line
Count
Source
70
1.72M
static inline int alloc_check(void) {
71
1.72M
  if(alloc_check_threshold == INT32_MAX)
72
1.70M
    return 0;
73
17.9k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
126
    return 1;
75
17.7k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
256
    return 1;
77
17.5k
  else {
78
17.5k
    return 0;
79
17.5k
  }
80
1.72M
}
stream_decoder.c:alloc_check
Line
Count
Source
70
1.42M
static inline int alloc_check(void) {
71
1.42M
  if(alloc_check_threshold == INT32_MAX)
72
1.22M
    return 0;
73
207k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
379
    return 1;
75
206k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
212
    return 1;
77
206k
  else {
78
206k
    return 0;
79
206k
  }
80
1.42M
}
stream_encoder.c:alloc_check
Line
Count
Source
70
357k
static inline int alloc_check(void) {
71
357k
  if(alloc_check_threshold == INT32_MAX)
72
273k
    return 0;
73
84.0k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
64
    return 1;
75
84.0k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
118
    return 1;
77
83.9k
  else {
78
83.9k
    return 0;
79
83.9k
  }
80
357k
}
ogg_decoder_aspect.c:alloc_check
Line
Count
Source
70
99.7k
static inline int alloc_check(void) {
71
99.7k
  if(alloc_check_threshold == INT32_MAX)
72
89.1k
    return 0;
73
10.5k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
57
    return 1;
75
10.5k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
10.5k
  else {
78
10.5k
    return 0;
79
10.5k
  }
80
99.7k
}
ogg_helper.c:alloc_check
Line
Count
Source
70
5.85k
static inline int alloc_check(void) {
71
5.85k
  if(alloc_check_threshold == INT32_MAX)
72
4.89k
    return 0;
73
961
  else if(alloc_check_counter++ == alloc_check_threshold)
74
31
    return 1;
75
930
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
930
  else {
78
930
    return 0;
79
930
  }
80
5.85k
}
bitwriter.c:alloc_check
Line
Count
Source
70
50.9k
static inline int alloc_check(void) {
71
50.9k
  if(alloc_check_threshold == INT32_MAX)
72
47.9k
    return 0;
73
2.97k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
68
    return 1;
75
2.90k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
2.90k
  else {
78
2.90k
    return 0;
79
2.90k
  }
80
50.9k
}
md5.c:alloc_check
Line
Count
Source
70
42.0k
static inline int alloc_check(void) {
71
42.0k
  if(alloc_check_threshold == INT32_MAX)
72
35.4k
    return 0;
73
6.60k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
181
    return 1;
75
6.41k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
4
    return 1;
77
6.41k
  else {
78
6.41k
    return 0;
79
6.41k
  }
80
42.0k
}
memory.c:alloc_check
Line
Count
Source
70
3.12M
static inline int alloc_check(void) {
71
3.12M
  if(alloc_check_threshold == INT32_MAX)
72
2.38M
    return 0;
73
735k
  else if(alloc_check_counter++ == alloc_check_threshold)
74
294
    return 1;
75
735k
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
735k
  else {
78
735k
    return 0;
79
735k
  }
80
3.12M
}
operations.c:alloc_check
Line
Count
Source
70
5.27k
static inline int alloc_check(void) {
71
5.27k
  if(alloc_check_threshold == INT32_MAX)
72
5.27k
    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.27k
}
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
35.5k
static inline int alloc_check(void) {
71
35.5k
  if(alloc_check_threshold == INT32_MAX)
72
35.5k
    return 0;
73
0
  else if(alloc_check_counter++ == alloc_check_threshold)
74
0
    return 1;
75
0
  else if(alloc_check_keep_failing && (alloc_check_counter > alloc_check_threshold))
76
0
    return 1;
77
0
  else {
78
0
    return 0;
79
0
  }
80
35.5k
}
Unexecuted instantiation: alloc.c:alloc_check
metadata.cpp:alloc_check()
Line
Count
Source
70
8.73k
static inline int alloc_check(void) {
71
8.73k
  if(alloc_check_threshold == INT32_MAX)
72
8.73k
    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
8.73k
}
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.73M
{
90
6.73M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
6.73M
  if(alloc_check())
93
956
    return NULL;
94
6.73M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
6.73M
  if(!size)
97
6.94k
    size++;
98
6.73M
  return malloc(size);
99
6.73M
}
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
3.49k
{
90
3.49k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.49k
  if(alloc_check())
93
0
    return NULL;
94
3.49k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.49k
  if(!size)
97
0
    size++;
98
3.49k
  return malloc(size);
99
3.49k
}
picture.c:safe_malloc_
Line
Count
Source
89
9.49k
{
90
9.49k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
9.49k
  if(alloc_check())
93
358
    return NULL;
94
9.13k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
9.13k
  if(!size)
97
0
    size++;
98
9.13k
  return malloc(size);
99
9.49k
}
Unexecuted instantiation: replaygain_analysis.c:safe_malloc_
Unexecuted instantiation: format.c:safe_malloc_
metadata_iterators.c:safe_malloc_
Line
Count
Source
89
1.47M
{
90
1.47M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.47M
  if(alloc_check())
93
0
    return NULL;
94
1.47M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.47M
  if(!size)
97
0
    size++;
98
1.47M
  return malloc(size);
99
1.47M
}
metadata_object.c:safe_malloc_
Line
Count
Source
89
1.61M
{
90
1.61M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
1.61M
  if(alloc_check())
93
250
    return NULL;
94
1.61M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
1.61M
  if(!size)
97
0
    size++;
98
1.61M
  return malloc(size);
99
1.61M
}
stream_decoder.c:safe_malloc_
Line
Count
Source
89
483k
{
90
483k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
483k
  if(alloc_check())
93
19
    return NULL;
94
483k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
483k
  if(!size)
97
6.94k
    size++;
98
483k
  return malloc(size);
99
483k
}
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.85k
{
90
5.85k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.85k
  if(alloc_check())
93
31
    return NULL;
94
5.82k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.82k
  if(!size)
97
0
    size++;
98
5.82k
  return malloc(size);
99
5.85k
}
Unexecuted instantiation: bitwriter.c:safe_malloc_
md5.c:safe_malloc_
Line
Count
Source
89
181
{
90
181
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
181
  if(alloc_check())
93
4
    return NULL;
94
177
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
177
  if(!size)
97
0
    size++;
98
177
  return malloc(size);
99
181
}
memory.c:safe_malloc_
Line
Count
Source
89
3.12M
{
90
3.12M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
3.12M
  if(alloc_check())
93
294
    return NULL;
94
3.12M
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
3.12M
  if(!size)
97
0
    size++;
98
3.12M
  return malloc(size);
99
3.12M
}
operations.c:safe_malloc_
Line
Count
Source
89
5.27k
{
90
5.27k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
5.27k
  if(alloc_check())
93
0
    return NULL;
94
5.27k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
5.27k
  if(!size)
97
0
    size++;
98
5.27k
  return malloc(size);
99
5.27k
}
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
8.73k
{
90
8.73k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
91
  /* Fail if requested */
92
8.73k
  if(alloc_check())
93
0
    return NULL;
94
8.73k
#endif
95
  /* malloc(0) is undefined; FLAC src convention is to always allocate */
96
8.73k
  if(!size)
97
0
    size++;
98
8.73k
  return malloc(size);
99
8.73k
}
100
101
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
102
static inline void *malloc_(size_t size)
103
386k
{
104
  /* Fail if requested */
105
386k
  if(alloc_check())
106
68
    return NULL;
107
386k
  return malloc(size);
108
386k
}
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
386k
{
104
  /* Fail if requested */
105
386k
  if(alloc_check())
106
68
    return NULL;
107
386k
  return malloc(size);
108
386k
}
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
990k
{
117
990k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
990k
  if(alloc_check())
120
800
    return NULL;
121
990k
#endif
122
990k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
990k
  return calloc(nmemb, size);
125
990k
}
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
93.2k
{
117
93.2k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
93.2k
  if(alloc_check())
120
123
    return NULL;
121
93.1k
#endif
122
93.1k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
93.1k
  return calloc(nmemb, size);
125
93.1k
}
stream_decoder.c:safe_calloc_
Line
Count
Source
116
539k
{
117
539k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
539k
  if(alloc_check())
120
495
    return NULL;
121
539k
#endif
122
539k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
539k
  return calloc(nmemb, size);
125
539k
}
stream_encoder.c:safe_calloc_
Line
Count
Source
116
357k
{
117
357k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
118
  /* Fail if requested */
119
357k
  if(alloc_check())
120
182
    return NULL;
121
357k
#endif
122
357k
  if(!nmemb || !size)
123
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
124
357k
  return calloc(nmemb, size);
125
357k
}
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.52M
{
131
6.52M
  size2 += size1;
132
6.52M
  if(size2 < size1)
133
0
    return 0;
134
6.52M
  return safe_malloc_(size2);
135
6.52M
}
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
3.49k
{
131
3.49k
  size2 += size1;
132
3.49k
  if(size2 < size1)
133
0
    return 0;
134
3.49k
  return safe_malloc_(size2);
135
3.49k
}
picture.c:safe_malloc_add_2op_
Line
Count
Source
130
7.44k
{
131
7.44k
  size2 += size1;
132
7.44k
  if(size2 < size1)
133
0
    return 0;
134
7.44k
  return safe_malloc_(size2);
135
7.44k
}
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
1.47M
{
131
1.47M
  size2 += size1;
132
1.47M
  if(size2 < size1)
133
0
    return 0;
134
1.47M
  return safe_malloc_(size2);
135
1.47M
}
metadata_object.c:safe_malloc_add_2op_
Line
Count
Source
130
1.43M
{
131
1.43M
  size2 += size1;
132
1.43M
  if(size2 < size1)
133
0
    return 0;
134
1.43M
  return safe_malloc_(size2);
135
1.43M
}
stream_decoder.c:safe_malloc_add_2op_
Line
Count
Source
130
465k
{
131
465k
  size2 += size1;
132
465k
  if(size2 < size1)
133
0
    return 0;
134
465k
  return safe_malloc_(size2);
135
465k
}
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.12M
{
131
3.12M
  size2 += size1;
132
3.12M
  if(size2 < size1)
133
0
    return 0;
134
3.12M
  return safe_malloc_(size2);
135
3.12M
}
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
8.73k
{
131
8.73k
  size2 += size1;
132
8.73k
  if(size2 < size1)
133
0
    return 0;
134
8.73k
  return safe_malloc_(size2);
135
8.73k
}
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
7.64k
{
150
7.64k
  size2 += size1;
151
7.64k
  if(size2 < size1)
152
0
    return 0;
153
7.64k
  size3 += size2;
154
7.64k
  if(size3 < size2)
155
0
    return 0;
156
7.64k
  size4 += size3;
157
7.64k
  if(size4 < size3)
158
0
    return 0;
159
7.64k
  return safe_malloc_(size4);
160
7.64k
}
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
7.64k
{
150
7.64k
  size2 += size1;
151
7.64k
  if(size2 < size1)
152
0
    return 0;
153
7.64k
  size3 += size2;
154
7.64k
  if(size3 < size2)
155
0
    return 0;
156
7.64k
  size4 += size3;
157
7.64k
  if(size4 < size3)
158
0
    return 0;
159
7.64k
  return safe_malloc_(size4);
160
7.64k
}
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
386k
{
189
386k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
386k
  size2 += size3;
192
386k
  if(size2 < size3)
193
0
    return 0;
194
386k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
386k
  return malloc_(size1*size2);
197
386k
}
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
386k
{
189
386k
  if(!size1 || (!size2 && !size3))
190
0
    return malloc(1); /* malloc(0) is undefined; FLAC src convention is to always allocate */
191
386k
  size2 += size3;
192
386k
  if(size2 < size3)
193
0
    return 0;
194
386k
  if(size1 > SIZE_MAX / size2)
195
0
    return 0;
196
386k
  return malloc_(size1*size2);
197
386k
}
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
3.79M
{
201
3.79M
  void *oldptr;
202
3.79M
  void *newptr;
203
3.79M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
3.79M
  if(alloc_check() && size > 0) {
206
377
    free(ptr);
207
377
    return NULL;
208
377
  }
209
3.79M
#endif
210
3.79M
  oldptr = ptr;
211
3.79M
  newptr = realloc(ptr, size);
212
3.79M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
3.79M
  return newptr;
215
3.79M
}
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
52.0k
{
201
52.0k
  void *oldptr;
202
52.0k
  void *newptr;
203
52.0k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
52.0k
  if(alloc_check() && size > 0) {
206
4
    free(ptr);
207
4
    return NULL;
208
4
  }
209
52.0k
#endif
210
52.0k
  oldptr = ptr;
211
52.0k
  newptr = realloc(ptr, size);
212
52.0k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
52.0k
  return newptr;
215
52.0k
}
format.c:safe_realloc_
Line
Count
Source
200
3.63M
{
201
3.63M
  void *oldptr;
202
3.63M
  void *newptr;
203
3.63M
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
3.63M
  if(alloc_check() && size > 0) {
206
178
    free(ptr);
207
178
    return NULL;
208
178
  }
209
3.63M
#endif
210
3.63M
  oldptr = ptr;
211
3.63M
  newptr = realloc(ptr, size);
212
3.63M
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
3.63M
  return newptr;
215
3.63M
}
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
9
    free(ptr);
207
9
    return NULL;
208
9
  }
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
11.7k
{
201
11.7k
  void *oldptr;
202
11.7k
  void *newptr;
203
11.7k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
11.7k
  if(alloc_check() && size > 0) {
206
5
    free(ptr);
207
5
    return NULL;
208
5
  }
209
11.7k
#endif
210
11.7k
  oldptr = ptr;
211
11.7k
  newptr = realloc(ptr, size);
212
11.7k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
11.7k
  return newptr;
215
11.7k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_
Unexecuted instantiation: bitwriter.c:safe_realloc_
md5.c:safe_realloc_
Line
Count
Source
200
41.8k
{
201
41.8k
  void *oldptr;
202
41.8k
  void *newptr;
203
41.8k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
41.8k
  if(alloc_check() && size > 0) {
206
181
    free(ptr);
207
181
    return NULL;
208
181
  }
209
41.6k
#endif
210
41.6k
  oldptr = ptr;
211
41.6k
  newptr = realloc(ptr, size);
212
41.6k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
41.6k
  return newptr;
215
41.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
35.5k
{
201
35.5k
  void *oldptr;
202
35.5k
  void *newptr;
203
35.5k
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
204
  /* Fail if requested */
205
35.5k
  if(alloc_check() && size > 0) {
206
0
    free(ptr);
207
0
    return NULL;
208
0
  }
209
35.5k
#endif
210
35.5k
  oldptr = ptr;
211
35.5k
  newptr = realloc(ptr, size);
212
35.5k
  if(size > 0 && newptr == 0)
213
0
    free(oldptr);
214
35.5k
  return newptr;
215
35.5k
}
Unexecuted instantiation: alloc.c:safe_realloc_
Unexecuted instantiation: metadata.cpp:safe_realloc_(void*, unsigned long)
216
217
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
218
static inline void *realloc_(void *ptr, size_t size)
219
460k
{
220
  /* Fail if requested */
221
460k
  if(alloc_check())
222
350
    return NULL;
223
460k
  return realloc(ptr, size);
224
460k
}
encode.c:realloc_
Line
Count
Source
219
176k
{
220
  /* Fail if requested */
221
176k
  if(alloc_check())
222
40
    return NULL;
223
176k
  return realloc(ptr, size);
224
176k
}
foreign_metadata.c:realloc_
Line
Count
Source
219
64.8k
{
220
  /* Fail if requested */
221
64.8k
  if(alloc_check())
222
14
    return NULL;
223
64.8k
  return realloc(ptr, size);
224
64.8k
}
Unexecuted instantiation: tool_flac.c:realloc_
Unexecuted instantiation: utf8.c:realloc_
iconvert.c:realloc_
Line
Count
Source
219
72.4k
{
220
  /* Fail if requested */
221
72.4k
  if(alloc_check())
222
167
    return NULL;
223
72.3k
  return realloc(ptr, size);
224
72.4k
}
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.54k
{
220
  /* Fail if requested */
221
7.54k
  if(alloc_check())
222
9
    return NULL;
223
7.53k
  return realloc(ptr, size);
224
7.54k
}
Unexecuted instantiation: stream_decoder.c:realloc_
Unexecuted instantiation: stream_encoder.c:realloc_
ogg_decoder_aspect.c:realloc_
Line
Count
Source
219
87.9k
{
220
  /* Fail if requested */
221
87.9k
  if(alloc_check())
222
52
    return NULL;
223
87.9k
  return realloc(ptr, size);
224
87.9k
}
Unexecuted instantiation: ogg_helper.c:realloc_
bitwriter.c:realloc_
Line
Count
Source
219
50.9k
{
220
  /* Fail if requested */
221
50.9k
  if(alloc_check())
222
68
    return NULL;
223
50.8k
  return realloc(ptr, size);
224
50.9k
}
Unexecuted instantiation: md5.c:realloc_
Unexecuted instantiation: memory.c:realloc_
Unexecuted instantiation: operations.c:realloc_
Unexecuted instantiation: options.c:realloc_
Unexecuted instantiation: utils.c:realloc_
Unexecuted instantiation: alloc.c:realloc_
Unexecuted instantiation: metadata.cpp:realloc_(void*, unsigned long)
225
#else
226
#define realloc_ realloc
227
#endif
228
229
230
static inline void *safe_realloc_nofree_add_2op_(void *ptr, size_t size1, size_t size2)
231
80.0k
{
232
80.0k
  size2 += size1;
233
80.0k
  if(size2 < size1)
234
0
    return 0;
235
80.0k
  return realloc_(ptr, size2);
236
80.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
72.4k
{
232
72.4k
  size2 += size1;
233
72.4k
  if(size2 < size1)
234
0
    return 0;
235
72.4k
  return realloc_(ptr, size2);
236
72.4k
}
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.54k
{
232
7.54k
  size2 += size1;
233
7.54k
  if(size2 < size1)
234
0
    return 0;
235
7.54k
  return realloc_(ptr, size2);
236
7.54k
}
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
35.5k
{
240
35.5k
  size2 += size1;
241
35.5k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
35.5k
  size3 += size2;
246
35.5k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
35.5k
  return safe_realloc_(ptr, size3);
251
35.5k
}
Unexecuted instantiation: encode.c:safe_realloc_add_3op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_add_3op_
Unexecuted instantiation: tool_flac.c:safe_realloc_add_3op_
Unexecuted instantiation: utf8.c:safe_realloc_add_3op_
Unexecuted instantiation: iconvert.c:safe_realloc_add_3op_
Unexecuted instantiation: picture.c:safe_realloc_add_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_add_3op_
Unexecuted instantiation: format.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata_object.c:safe_realloc_add_3op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_add_3op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_add_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_add_3op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_add_3op_
Unexecuted instantiation: bitwriter.c:safe_realloc_add_3op_
Unexecuted instantiation: md5.c:safe_realloc_add_3op_
Unexecuted instantiation: memory.c:safe_realloc_add_3op_
Unexecuted instantiation: operations.c:safe_realloc_add_3op_
Unexecuted instantiation: options.c:safe_realloc_add_3op_
utils.c:safe_realloc_add_3op_
Line
Count
Source
239
35.5k
{
240
35.5k
  size2 += size1;
241
35.5k
  if(size2 < size1) {
242
0
    free(ptr);
243
0
    return 0;
244
0
  }
245
35.5k
  size3 += size2;
246
35.5k
  if(size3 < size2) {
247
0
    free(ptr);
248
0
    return 0;
249
0
  }
250
35.5k
  return safe_realloc_(ptr, size3);
251
35.5k
}
Unexecuted instantiation: alloc.c:safe_realloc_add_3op_
Unexecuted instantiation: metadata.cpp:safe_realloc_add_3op_(void*, unsigned long, unsigned long, unsigned long)
252
253
static inline void *safe_realloc_nofree_add_3op_(void *ptr, size_t size1, size_t size2, size_t size3)
254
0
{
255
0
  size2 += size1;
256
0
  if(size2 < size1)
257
0
    return 0;
258
0
  size3 += size2;
259
0
  if(size3 < size2)
260
0
    return 0;
261
0
  return realloc_(ptr, size3);
262
0
}
Unexecuted instantiation: encode.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: picture.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: format.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: md5.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: options.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_add_3op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_add_3op_(void*, unsigned long, unsigned long, unsigned long)
263
264
static inline void *safe_realloc_nofree_add_4op_(void *ptr, size_t size1, size_t size2, size_t size3, size_t size4)
265
0
{
266
0
  size2 += size1;
267
0
  if(size2 < size1)
268
0
    return 0;
269
0
  size3 += size2;
270
0
  if(size3 < size2)
271
0
    return 0;
272
0
  size4 += size3;
273
0
  if(size4 < size3)
274
0
    return 0;
275
0
  return realloc_(ptr, size4);
276
0
}
Unexecuted instantiation: encode.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: tool_flac.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: utf8.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: iconvert.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: picture.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: format.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata_object.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: stream_decoder.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: stream_encoder.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: bitwriter.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: md5.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: options.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_add_4op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_add_4op_(void*, unsigned long, unsigned long, unsigned long, unsigned long)
277
278
static inline void *safe_realloc_mul_2op_(void *ptr, size_t size1, size_t size2)
279
29.2k
{
280
29.2k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
29.2k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
29.2k
  return safe_realloc_(ptr, size1*size2);
287
29.2k
}
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
11.7k
{
280
11.7k
  if(!size1 || !size2)
281
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
282
11.7k
  if(size1 > SIZE_MAX / size2) {
283
0
    free(ptr);
284
0
    return 0;
285
0
  }
286
11.7k
  return safe_realloc_(ptr, size1*size2);
287
11.7k
}
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
380k
{
291
380k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
380k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
380k
  return realloc_(ptr, size1*size2);
296
380k
}
encode.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
176k
{
291
176k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
176k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
176k
  return realloc_(ptr, size1*size2);
296
176k
}
foreign_metadata.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
64.8k
{
291
64.8k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
64.8k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
64.8k
  return realloc_(ptr, size1*size2);
296
64.8k
}
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
87.9k
{
291
87.9k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
87.9k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
87.9k
  return realloc_(ptr, size1*size2);
296
87.9k
}
Unexecuted instantiation: ogg_helper.c:safe_realloc_nofree_mul_2op_
bitwriter.c:safe_realloc_nofree_mul_2op_
Line
Count
Source
290
50.9k
{
291
50.9k
  if(!size1 || !size2)
292
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
293
50.9k
  if(size1 > SIZE_MAX / size2)
294
0
    return 0;
295
50.9k
  return realloc_(ptr, size1*size2);
296
50.9k
}
Unexecuted instantiation: md5.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: memory.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: operations.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: options.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: utils.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: alloc.c:safe_realloc_nofree_mul_2op_
Unexecuted instantiation: metadata.cpp:safe_realloc_nofree_mul_2op_(void*, unsigned long, unsigned long)
297
298
/* size1 * (size2 + size3) */
299
static inline void *safe_realloc_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
300
0
{
301
0
  if(!size1 || (!size2 && !size3))
302
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
303
0
  size2 += size3;
304
0
  if(size2 < size3) {
305
0
    free(ptr);
306
0
    return 0;
307
0
  }
308
0
  return safe_realloc_mul_2op_(ptr, size1, size2);
309
0
}
Unexecuted instantiation: encode.c:safe_realloc_muladd2_
Unexecuted instantiation: foreign_metadata.c:safe_realloc_muladd2_
Unexecuted instantiation: tool_flac.c:safe_realloc_muladd2_
Unexecuted instantiation: utf8.c:safe_realloc_muladd2_
Unexecuted instantiation: iconvert.c:safe_realloc_muladd2_
Unexecuted instantiation: picture.c:safe_realloc_muladd2_
Unexecuted instantiation: replaygain_analysis.c:safe_realloc_muladd2_
Unexecuted instantiation: format.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata_iterators.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata_object.c:safe_realloc_muladd2_
Unexecuted instantiation: stream_decoder.c:safe_realloc_muladd2_
Unexecuted instantiation: stream_encoder.c:safe_realloc_muladd2_
Unexecuted instantiation: ogg_decoder_aspect.c:safe_realloc_muladd2_
Unexecuted instantiation: ogg_helper.c:safe_realloc_muladd2_
Unexecuted instantiation: bitwriter.c:safe_realloc_muladd2_
Unexecuted instantiation: md5.c:safe_realloc_muladd2_
Unexecuted instantiation: memory.c:safe_realloc_muladd2_
Unexecuted instantiation: operations.c:safe_realloc_muladd2_
Unexecuted instantiation: options.c:safe_realloc_muladd2_
Unexecuted instantiation: utils.c:safe_realloc_muladd2_
Unexecuted instantiation: alloc.c:safe_realloc_muladd2_
Unexecuted instantiation: metadata.cpp:safe_realloc_muladd2_(void*, unsigned long, unsigned long, unsigned long)
310
311
/* size1 * (size2 + size3) */
312
static inline void *safe_realloc_nofree_muladd2_(void *ptr, size_t size1, size_t size2, size_t size3)
313
241k
{
314
241k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
241k
  size2 += size3;
317
241k
  if(size2 < size3)
318
0
    return 0;
319
241k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
241k
}
encode.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
176k
{
314
176k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
176k
  size2 += size3;
317
176k
  if(size2 < size3)
318
0
    return 0;
319
176k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
176k
}
foreign_metadata.c:safe_realloc_nofree_muladd2_
Line
Count
Source
313
64.8k
{
314
64.8k
  if(!size1 || (!size2 && !size3))
315
0
    return realloc(ptr, 0); /* preserve POSIX realloc(ptr, 0) semantics */
316
64.8k
  size2 += size3;
317
64.8k
  if(size2 < size3)
318
0
    return 0;
319
64.8k
  return safe_realloc_nofree_mul_2op_(ptr, size1, size2);
320
64.8k
}
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