m_property: don't parse empty string as 0

Nice strtol() usage error.
This commit is contained in:
wm4 2014-03-30 13:29:56 +02:00
parent 1a23ca2766
commit 7cc985f3d0
1 changed files with 2 additions and 1 deletions

View File

@ -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;