Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
b1306823
Commit
b1306823
authored
Dec 17, 2014
by
Vittorio Giovara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check memory errors from av_strdup()
parent
9745f19f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
8 deletions
+32
-8
avconv_opt.c
avconv_opt.c
+2
-0
avprobe.c
avprobe.c
+4
-0
cmdutils.c
cmdutils.c
+9
-1
matroskaenc.c
libavformat/matroskaenc.c
+12
-4
opt.c
libavutil/opt.c
+5
-3
No files found.
avconv_opt.c
View file @
b1306823
...
@@ -213,6 +213,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
...
@@ -213,6 +213,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
arg
++
;
arg
++
;
}
}
map
=
av_strdup
(
arg
);
map
=
av_strdup
(
arg
);
if
(
!
map
)
return
AVERROR
(
ENOMEM
);
/* parse sync stream first, just pick first matching stream */
/* parse sync stream first, just pick first matching stream */
if
(
sync
=
strchr
(
map
,
','
))
{
if
(
sync
=
strchr
(
map
,
','
))
{
...
...
avprobe.c
View file @
b1306823
...
@@ -302,6 +302,8 @@ static void old_print_object_header(const char *name)
...
@@ -302,6 +302,8 @@ static void old_print_object_header(const char *name)
return
;
return
;
str
=
p
=
av_strdup
(
name
);
str
=
p
=
av_strdup
(
name
);
if
(
!
str
)
return
;
while
(
*
p
)
{
while
(
*
p
)
{
*
p
=
av_toupper
(
*
p
);
*
p
=
av_toupper
(
*
p
);
p
++
;
p
++
;
...
@@ -319,6 +321,8 @@ static void old_print_object_footer(const char *name)
...
@@ -319,6 +321,8 @@ static void old_print_object_footer(const char *name)
return
;
return
;
str
=
p
=
av_strdup
(
name
);
str
=
p
=
av_strdup
(
name
);
if
(
!
str
)
return
;
while
(
*
p
)
{
while
(
*
p
)
{
*
p
=
av_toupper
(
*
p
);
*
p
=
av_toupper
(
*
p
);
p
++
;
p
++
;
...
...
cmdutils.c
View file @
b1306823
...
@@ -261,10 +261,14 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
...
@@ -261,10 +261,14 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
if
(
po
->
flags
&
OPT_SPEC
)
{
if
(
po
->
flags
&
OPT_SPEC
)
{
SpecifierOpt
**
so
=
dst
;
SpecifierOpt
**
so
=
dst
;
char
*
p
=
strchr
(
opt
,
':'
);
char
*
p
=
strchr
(
opt
,
':'
);
char
*
str
;
dstcount
=
(
int
*
)(
so
+
1
);
dstcount
=
(
int
*
)(
so
+
1
);
*
so
=
grow_array
(
*
so
,
sizeof
(
**
so
),
dstcount
,
*
dstcount
+
1
);
*
so
=
grow_array
(
*
so
,
sizeof
(
**
so
),
dstcount
,
*
dstcount
+
1
);
(
*
so
)[
*
dstcount
-
1
].
specifier
=
av_strdup
(
p
?
p
+
1
:
""
);
str
=
av_strdup
(
p
?
p
+
1
:
""
);
if
(
!
str
)
return
AVERROR
(
ENOMEM
);
(
*
so
)[
*
dstcount
-
1
].
specifier
=
str
;
dst
=
&
(
*
so
)[
*
dstcount
-
1
].
u
;
dst
=
&
(
*
so
)[
*
dstcount
-
1
].
u
;
}
}
...
@@ -272,6 +276,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
...
@@ -272,6 +276,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
char
*
str
;
char
*
str
;
str
=
av_strdup
(
arg
);
str
=
av_strdup
(
arg
);
av_freep
(
dst
);
av_freep
(
dst
);
if
(
!
str
)
return
AVERROR
(
ENOMEM
);
*
(
char
**
)
dst
=
str
;
*
(
char
**
)
dst
=
str
;
}
else
if
(
po
->
flags
&
OPT_BOOL
||
po
->
flags
&
OPT_INT
)
{
}
else
if
(
po
->
flags
&
OPT_BOOL
||
po
->
flags
&
OPT_INT
)
{
*
(
int
*
)
dst
=
parse_number_or_die
(
opt
,
arg
,
OPT_INT64
,
INT_MIN
,
INT_MAX
);
*
(
int
*
)
dst
=
parse_number_or_die
(
opt
,
arg
,
OPT_INT64
,
INT_MIN
,
INT_MAX
);
...
@@ -1350,6 +1356,8 @@ int show_help(void *optctx, const char *opt, const char *arg)
...
@@ -1350,6 +1356,8 @@ int show_help(void *optctx, const char *opt, const char *arg)
av_log_set_callback
(
log_callback_help
);
av_log_set_callback
(
log_callback_help
);
topic
=
av_strdup
(
arg
?
arg
:
""
);
topic
=
av_strdup
(
arg
?
arg
:
""
);
if
(
!
topic
)
return
AVERROR
(
ENOMEM
);
par
=
strchr
(
topic
,
'='
);
par
=
strchr
(
topic
,
'='
);
if
(
par
)
if
(
par
)
*
par
++
=
0
;
*
par
++
=
0
;
...
...
libavformat/matroskaenc.c
View file @
b1306823
...
@@ -936,13 +936,16 @@ static int mkv_write_chapters(AVFormatContext *s)
...
@@ -936,13 +936,16 @@ static int mkv_write_chapters(AVFormatContext *s)
return
0
;
return
0
;
}
}
static
void
mkv_write_simpletag
(
AVIOContext
*
pb
,
AVDictionaryEntry
*
t
)
static
int
mkv_write_simpletag
(
AVIOContext
*
pb
,
AVDictionaryEntry
*
t
)
{
{
uint8_t
*
key
=
av_strdup
(
t
->
key
);
uint8_t
*
key
=
av_strdup
(
t
->
key
);
uint8_t
*
p
=
key
;
uint8_t
*
p
=
key
;
const
uint8_t
*
lang
=
NULL
;
const
uint8_t
*
lang
=
NULL
;
ebml_master
tag
;
ebml_master
tag
;
if
(
!
key
)
return
AVERROR
(
ENOMEM
);
if
((
p
=
strrchr
(
p
,
'-'
))
&&
if
((
p
=
strrchr
(
p
,
'-'
))
&&
(
lang
=
av_convert_lang_to
(
p
+
1
,
AV_LANG_ISO639_2_BIBL
)))
(
lang
=
av_convert_lang_to
(
p
+
1
,
AV_LANG_ISO639_2_BIBL
)))
*
p
=
0
;
*
p
=
0
;
...
@@ -964,6 +967,7 @@ static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
...
@@ -964,6 +967,7 @@ static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
end_ebml_master
(
pb
,
tag
);
end_ebml_master
(
pb
,
tag
);
av_freep
(
&
key
);
av_freep
(
&
key
);
return
0
;
}
}
static
int
mkv_write_tag
(
AVFormatContext
*
s
,
AVDictionary
*
m
,
unsigned
int
elementid
,
static
int
mkv_write_tag
(
AVFormatContext
*
s
,
AVDictionary
*
m
,
unsigned
int
elementid
,
...
@@ -987,10 +991,14 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
...
@@ -987,10 +991,14 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
put_ebml_uint
(
s
->
pb
,
elementid
,
uid
);
put_ebml_uint
(
s
->
pb
,
elementid
,
uid
);
end_ebml_master
(
s
->
pb
,
targets
);
end_ebml_master
(
s
->
pb
,
targets
);
while
((
t
=
av_dict_get
(
m
,
""
,
t
,
AV_DICT_IGNORE_SUFFIX
)))
while
((
t
=
av_dict_get
(
m
,
""
,
t
,
AV_DICT_IGNORE_SUFFIX
)))
{
if
(
av_strcasecmp
(
t
->
key
,
"title"
)
&&
if
(
av_strcasecmp
(
t
->
key
,
"title"
)
&&
av_strcasecmp
(
t
->
key
,
"encoding_tool"
))
av_strcasecmp
(
t
->
key
,
"encoding_tool"
))
{
mkv_write_simpletag
(
s
->
pb
,
t
);
ret
=
mkv_write_simpletag
(
s
->
pb
,
t
);
if
(
ret
<
0
)
return
ret
;
}
}
end_ebml_master
(
s
->
pb
,
tag
);
end_ebml_master
(
s
->
pb
,
tag
);
return
0
;
return
0
;
...
...
libavutil/opt.c
View file @
b1306823
...
@@ -138,7 +138,7 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
...
@@ -138,7 +138,7 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
{
{
av_freep
(
dst
);
av_freep
(
dst
);
*
dst
=
av_strdup
(
val
);
*
dst
=
av_strdup
(
val
);
return
0
;
return
*
dst
?
0
:
AVERROR
(
ENOMEM
)
;
}
}
#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \
#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \
...
@@ -350,7 +350,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
...
@@ -350,7 +350,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
*
out_val
=
av_strdup
(
*
(
uint8_t
**
)
dst
);
*
out_val
=
av_strdup
(
*
(
uint8_t
**
)
dst
);
else
else
*
out_val
=
av_strdup
(
""
);
*
out_val
=
av_strdup
(
""
);
return
0
;
return
*
out_val
?
0
:
AVERROR
(
ENOMEM
)
;
case
AV_OPT_TYPE_BINARY
:
case
AV_OPT_TYPE_BINARY
:
len
=
*
(
int
*
)(((
uint8_t
*
)
dst
)
+
sizeof
(
uint8_t
*
));
len
=
*
(
int
*
)(((
uint8_t
*
)
dst
)
+
sizeof
(
uint8_t
*
));
if
((
uint64_t
)
len
*
2
+
1
>
INT_MAX
)
if
((
uint64_t
)
len
*
2
+
1
>
INT_MAX
)
...
@@ -368,7 +368,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
...
@@ -368,7 +368,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
if
(
ret
>=
sizeof
(
buf
))
if
(
ret
>=
sizeof
(
buf
))
return
AVERROR
(
EINVAL
);
return
AVERROR
(
EINVAL
);
*
out_val
=
av_strdup
(
buf
);
*
out_val
=
av_strdup
(
buf
);
return
0
;
return
*
out_val
?
0
:
AVERROR
(
ENOMEM
)
;
}
}
static
int
get_number
(
void
*
obj
,
const
char
*
name
,
double
*
num
,
int
*
den
,
int64_t
*
intnum
,
static
int
get_number
(
void
*
obj
,
const
char
*
name
,
double
*
num
,
int
*
den
,
int64_t
*
intnum
,
...
@@ -828,6 +828,8 @@ int main(void)
...
@@ -828,6 +828,8 @@ int main(void)
test_ctx
.
class
=
&
test_class
;
test_ctx
.
class
=
&
test_class
;
av_opt_set_defaults
(
&
test_ctx
);
av_opt_set_defaults
(
&
test_ctx
);
test_ctx
.
string
=
av_strdup
(
"default"
);
test_ctx
.
string
=
av_strdup
(
"default"
);
if
(
!
test_ctx
.
string
)
return
AVERROR
(
ENOMEM
);
av_log_set_level
(
AV_LOG_DEBUG
);
av_log_set_level
(
AV_LOG_DEBUG
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment