summaryrefslogtreecommitdiffstats
path: root/options/m_property.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-30 13:29:56 +0200
committerwm4 <wm4@nowhere>2014-03-30 13:29:56 +0200
commit7cc985f3d01dbb27f17231793713caa6565e42ee (patch)
tree96f8761801ccddc231fa1f9383ccb6b3bc4fffef /options/m_property.c
parent1a23ca27663f80d730dd764122ededd2ac9c01b9 (diff)
downloadmpv-7cc985f3d01dbb27f17231793713caa6565e42ee.tar.bz2
mpv-7cc985f3d01dbb27f17231793713caa6565e42ee.tar.xz
m_property: don't parse empty string as 0
Nice strtol() usage error.
Diffstat (limited to 'options/m_property.c')
-rw-r--r--options/m_property.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/options/m_property.c b/options/m_property.c
index 4efe68f83d..ff23979ade 100644
--- a/options/m_property.c
+++ b/options/m_property.c
@@ -576,9 +576,10 @@ int m_property_read_list(int action, void *arg, int count,
// This is expected of the form "123" or "123/rest"
char *next = strchr(ka->key, '/');
char *end = NULL;
+ const char *key_end = ka->key + strlen(ka->key);
long int item = strtol(ka->key, &end, 10);
// not a number, trailing characters, etc.
- if (end != ka->key + strlen(ka->key) && end != next)
+ if ((end != key_end || ka->key == key_end) && end != next)
return M_PROPERTY_UNKNOWN;
if (item < 0 || item >= count)
return M_PROPERTY_UNKNOWN;