summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-04-29 08:00:52 -0700
committerKevin Mitchell <kevmitch@gmail.com>2014-04-29 08:31:44 -0700
commite3e565c194580c0601568528b9bd2033ae0e6f70 (patch)
tree0090511f30817c1de04fc4295fe9a10f505b54d3
parent164cfeba56af9806f7b164842d50a4ea1627979a (diff)
downloadmpv-e3e565c194580c0601568528b9bd2033ae0e6f70.tar.bz2
mpv-e3e565c194580c0601568528b9bd2033ae0e6f70.tar.xz
vf-metadata: fix handling of NULL metadata
lavfi would segfault due to a NULL dereference if it was asked for its metadata and none had been allocated (oops). This happens for libav which has no concept of filter metadata.
-rw-r--r--player/command.c27
-rw-r--r--video/filter/vf_lavfi.c11
2 files changed, 23 insertions, 15 deletions
diff --git a/player/command.c b/player/command.c
index d938e48162..da978d2846 100644
--- a/player/command.c
+++ b/player/command.c
@@ -950,19 +950,24 @@ static int mp_property_vf_metadata(m_option_t *prop, int action, void *arg,
char *rem;
m_property_split_path(ka->key, &key, &rem);
struct mp_tags vf_metadata;
- if (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)
- == CONTROL_UNKNOWN)
+ switch (vf_control_by_label(vf, VFCTRL_GET_METADATA, &vf_metadata, key)) {
+ case CONTROL_NA:
+ return M_PROPERTY_UNAVAILABLE;
+ case CONTROL_UNKNOWN:
return M_PROPERTY_UNKNOWN;
-
- if (strlen(rem)) {
- struct m_property_action_arg next_ka = *ka;
- next_ka.key = rem;
- return tag_property(prop, M_PROPERTY_KEY_ACTION, &next_ka,
- &vf_metadata);
- } else {
- return tag_property(prop, ka->action, ka->arg, &vf_metadata);
+ case CONTROL_OK:
+ if (strlen(rem)) {
+ struct m_property_action_arg next_ka = *ka;
+ next_ka.key = rem;
+ return tag_property(prop, M_PROPERTY_KEY_ACTION, &next_ka,
+ &vf_metadata);
+ } else {
+ return tag_property(prop, ka->action, ka->arg, &vf_metadata);
+ }
+ return M_PROPERTY_OK;
+ default:
+ return M_PROPERTY_ERROR;
}
- return M_PROPERTY_OK;
}
}
return M_PROPERTY_NOT_IMPLEMENTED;
diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c
index f2de4fe9a4..2002c97d16 100644
--- a/video/filter/vf_lavfi.c
+++ b/video/filter/vf_lavfi.c
@@ -334,10 +334,13 @@ static int control(vf_instance_t *vf, int request, void *data)
case VFCTRL_SEEK_RESET:
reset(vf);
return CONTROL_OK;
- case VFCTRL_GET_METADATA:{
- *(struct mp_tags*) data = *vf->priv->metadata;
- return CONTROL_OK;
- }
+ case VFCTRL_GET_METADATA:
+ if (vf->priv && vf->priv->metadata) {
+ *(struct mp_tags*) data = *vf->priv->metadata;
+ return CONTROL_OK;
+ } else {
+ return CONTROL_NA;
+ }
}
return CONTROL_UNKNOWN;
}