command: make m_property_strdup_ro with NULL mean unavailable

This catches a few cases which basically call:

    m_property_strdup_ro(..., ..., NULL)

which would return NULL strings. This should generally be avoided
(although it's allowed due to reasons), and it seems most callers
actually intend this to mean M_PROPERTY_UNAVAILABLE.
This commit is contained in:
wm4 2014-09-01 21:50:54 +02:00
parent 4124a175e1
commit 0aaf688c2d
1 changed files with 2 additions and 0 deletions

View File

@ -442,6 +442,8 @@ int m_property_double_ro(int action, void *arg, double var)
int m_property_strdup_ro(int action, void* arg, const char *var) int m_property_strdup_ro(int action, void* arg, const char *var)
{ {
if (!var)
return M_PROPERTY_UNAVAILABLE;
switch (action) { switch (action) {
case M_PROPERTY_GET: case M_PROPERTY_GET:
*(char **)arg = talloc_strdup(NULL, var); *(char **)arg = talloc_strdup(NULL, var);