diff options
author | wm4 <wm4@nowhere> | 2014-03-30 13:50:23 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-30 13:50:23 +0200 |
commit | 01f3e462900bbd6b9cfe5aa27f81c8847dca89d4 (patch) | |
tree | 86c05f0f786211506f9b95c68e996d09ec9e96d7 | |
parent | 5cd20c73208e6fca063f829c86dd4cd22f55a31a (diff) | |
download | mpv-01f3e462900bbd6b9cfe5aa27f81c8847dca89d4.tar.bz2 mpv-01f3e462900bbd6b9cfe5aa27f81c8847dca89d4.tar.xz |
command: fix access to "metadata/list" property
The function tag_property() in command.c passed a key action with empty
path to m_property_read_list. This is normally not valid, because key
actions are supposed to access sub-paths. But it's kind of inconvenient
to check for this case in tag_property(). So make it valid by providing
a m_property_unkey() function, which turns a key access to "" into a
top-level action.
-rw-r--r-- | options/m_property.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/options/m_property.c b/options/m_property.c index d235c27c95..23d328a0f9 100644 --- a/options/m_property.c +++ b/options/m_property.c @@ -246,6 +246,19 @@ bool m_property_split_path(const char *path, bstr *prefix, char **rem) } } +// If *action is M_PROPERTY_KEY_ACTION, but the associated path is "", then +// make this into a top-level action. +static void m_property_unkey(int *action, void **arg) +{ + if (*action == M_PROPERTY_KEY_ACTION) { + struct m_property_action_arg *ka = *arg; + if (!ka->key[0]) { + *action = ka->action; + *arg = ka->arg; + } + } +} + static int m_property_do_bstr(const m_option_t *prop_list, bstr name, int action, void *arg, void *ctx) { @@ -524,6 +537,7 @@ int m_property_read_sub(const struct m_sub_property *props, int action, void *ar int m_property_read_list(int action, void *arg, int count, m_get_item_cb get_item, void *ctx) { + m_property_unkey(&action, &arg); switch (action) { case M_PROPERTY_GET_TYPE: *(struct m_option *)arg = (struct m_option){.type = CONF_TYPE_NODE}; |