mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
Merge commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e'
* commit 'b1306823d0b3ae998c8e10ad832004eb13bdd93e': check memory errors from av_strdup() Conflicts: avprobe.c libavformat/matroskaenc.c libavutil/opt.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
988d27b802
10
cmdutils.c
10
cmdutils.c
@ -290,10 +290,14 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
|
||||
if (po->flags & OPT_SPEC) {
|
||||
SpecifierOpt **so = dst;
|
||||
char *p = strchr(opt, ':');
|
||||
char *str;
|
||||
|
||||
dstcount = (int *)(so + 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;
|
||||
}
|
||||
|
||||
@ -301,6 +305,8 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
|
||||
char *str;
|
||||
str = av_strdup(arg);
|
||||
av_freep(dst);
|
||||
if (!str)
|
||||
return AVERROR(ENOMEM);
|
||||
*(char **)dst = str;
|
||||
} else if (po->flags & OPT_BOOL || po->flags & OPT_INT) {
|
||||
*(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX);
|
||||
@ -1816,6 +1822,8 @@ int show_help(void *optctx, const char *opt, const char *arg)
|
||||
av_log_set_callback(log_callback_help);
|
||||
|
||||
topic = av_strdup(arg ? arg : "");
|
||||
if (!topic)
|
||||
return AVERROR(ENOMEM);
|
||||
par = strchr(topic, '=');
|
||||
if (par)
|
||||
*par++ = 0;
|
||||
|
@ -231,6 +231,8 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
|
||||
arg++;
|
||||
}
|
||||
map = av_strdup(arg);
|
||||
if (!map)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
/* parse sync stream first, just pick first matching stream */
|
||||
if (sync = strchr(map, ',')) {
|
||||
|
@ -1084,13 +1084,16 @@ static int mkv_write_chapters(AVFormatContext *s)
|
||||
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 *p = key;
|
||||
const uint8_t *lang = NULL;
|
||||
ebml_master tag;
|
||||
|
||||
if (!key)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if ((p = strrchr(p, '-')) &&
|
||||
(lang = av_convert_lang_to(p + 1, AV_LANG_ISO639_2_BIBL)))
|
||||
*p = 0;
|
||||
@ -1112,6 +1115,7 @@ static void mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t)
|
||||
end_ebml_master(pb, tag);
|
||||
|
||||
av_freep(&key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid,
|
||||
@ -1135,11 +1139,15 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
|
||||
put_ebml_uint(s->pb, elementid, uid);
|
||||
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") &&
|
||||
av_strcasecmp(t->key, "stereo_mode") &&
|
||||
av_strcasecmp(t->key, "encoding_tool"))
|
||||
mkv_write_simpletag(s->pb, t);
|
||||
av_strcasecmp(t->key, "encoding_tool")) {
|
||||
ret = mkv_write_simpletag(s->pb, t);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
end_ebml_master(s->pb, tag);
|
||||
return 0;
|
||||
|
@ -162,7 +162,7 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
|
||||
{
|
||||
av_freep(dst);
|
||||
*dst = av_strdup(val);
|
||||
return 0;
|
||||
return *dst ? 0 : AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
#define DEFAULT_NUMVAL(opt) ((opt->type == AV_OPT_TYPE_INT64 || \
|
||||
@ -711,7 +711,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
||||
*out_val = av_strdup(*(uint8_t**)dst);
|
||||
else
|
||||
*out_val = av_strdup("");
|
||||
return 0;
|
||||
return *out_val ? 0 : AVERROR(ENOMEM);
|
||||
case AV_OPT_TYPE_BINARY:
|
||||
len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *));
|
||||
if ((uint64_t)len*2 + 1 > INT_MAX)
|
||||
@ -757,7 +757,7 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
|
||||
if (ret >= sizeof(buf))
|
||||
return AVERROR(EINVAL);
|
||||
*out_val = av_strdup(buf);
|
||||
return 0;
|
||||
return *out_val ? 0 : AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
static int get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum,
|
||||
|
Loading…
x
Reference in New Issue
Block a user