diff options
author | David Robillard <d@drobilla.net> | 2011-05-18 03:15:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-18 03:15:28 +0000 |
commit | f5a258e0b9740a57dd14c93a65e1b19ab5fd964f (patch) | |
tree | 7a24a1063d9d00bb86bf49b490af6be094823343 /src | |
parent | d5235c880b6e23e4618ae02f38981051e599741e (diff) | |
download | lilv-f5a258e0b9740a57dd14c93a65e1b19ab5fd964f.tar.gz lilv-f5a258e0b9740a57dd14c93a65e1b19ab5fd964f.tar.bz2 lilv-f5a258e0b9740a57dd14c93a65e1b19ab5fd964f.zip |
Fix lilv_plugin_get_port_ranges_float crash when range values aren't float.
Make lilv_plugin_get_port_ranges_float avoid range search if output array is not given for min/max/default.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3275 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/plugin.c b/src/plugin.c index a31558f..25cc781 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -453,18 +453,25 @@ lilv_plugin_get_port_ranges_float(const LilvPlugin* p, float* def_values) { lilv_plugin_load_ports_if_necessary(p); + LilvNode *min, *max, *def; + LilvNode** minptr = min_values ? &min : NULL; + LilvNode** maxptr = max_values ? &max : NULL; + LilvNode** defptr = def_values ? &def : NULL; + for (uint32_t i = 0; i < p->num_ports; ++i) { - LilvNode *def, *min, *max; - lilv_port_get_range(p, p->ports[i], &def, &min, &max); + lilv_port_get_range(p, p->ports[i], defptr, minptr, maxptr); - if (min_values) - min_values[i] = min ? lilv_node_as_float(min) : NAN; + min_values[i] = (minptr && lilv_node_is_float(min)) + ? lilv_node_as_float(min) + : NAN; - if (max_values) - max_values[i] = max ? lilv_node_as_float(max) : NAN; + max_values[i] = (maxptr && lilv_node_is_float(max)) + ? lilv_node_as_float(max) + : NAN; - if (def_values) - def_values[i] = def ? lilv_node_as_float(def) : NAN; + def_values[i] = (defptr && lilv_node_is_float(def)) + ? lilv_node_as_float(def) + : NAN; lilv_node_free(def); lilv_node_free(min); |