diff options
author | wm4 <wm4@nowhere> | 2015-01-12 14:33:56 +0100 |
---|---|---|
committer | Diogo Franco (Kovensky) <diogomfranco@gmail.com> | 2015-01-25 17:00:08 +0900 |
commit | 947a791992aa8b99e7e43f9a7c35866fe2e3c2f9 (patch) | |
tree | 656c2ea707eb033f2c3f6a6ea2facb09c55eb10c | |
parent | 42f82c5ccfc1b4be7c5e085a2aa4160d3b5d032d (diff) | |
download | mpv-947a791992aa8b99e7e43f9a7c35866fe2e3c2f9.tar.bz2 mpv-947a791992aa8b99e7e43f9a7c35866fe2e3c2f9.tar.xz |
player: don't set tag strings to NULL
bstr is a bounded string type, consisting of a pointer and a length
value. If the length is 0, the pointer can be NULL. This is somewhat
logical due to how this abstraction works, but it can leak when
converting to C strings.
talloc_strndup() returns NULL instead of "" in this case, which broke
some other code. Use bstrto0() instead, which is the "proper" function
to convert bstr to char*.
Fixes #1462.
-rw-r--r-- | common/tags.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/tags.c b/common/tags.c index bc9d98ea2f..92aaaad337 100644 --- a/common/tags.c +++ b/common/tags.c @@ -29,15 +29,15 @@ void mp_tags_set_bstr(struct mp_tags *tags, bstr key, bstr value) for (int n = 0; n < tags->num_keys; n++) { if (bstrcasecmp0(key, tags->keys[n]) == 0) { talloc_free(tags->values[n]); - tags->values[n] = talloc_strndup(tags, value.start, value.len); + tags->values[n] = bstrto0(tags, value); return; } } MP_RESIZE_ARRAY(tags, tags->keys, tags->num_keys + 1); MP_RESIZE_ARRAY(tags, tags->values, tags->num_keys + 1); - tags->keys[tags->num_keys] = talloc_strndup(tags, key.start, key.len); - tags->values[tags->num_keys] = talloc_strndup(tags, value.start, value.len); + tags->keys[tags->num_keys] = bstrto0(tags, key); + tags->values[tags->num_keys] = bstrto0(tags, value); tags->num_keys++; } |