bbf: fix a crash when the 'access' option is not defined in the JSON file

This commit is contained in:
Amin Ben Ramdhane 2021-11-25 17:34:07 +01:00
parent d64075bda9
commit 8d2581bacb
2 changed files with 8 additions and 7 deletions

View file

@ -1532,6 +1532,9 @@ static void parse_obj(char *object, json_object *jobj, DMOBJ *pobj, int index, i
pobj[index].leaf = NULL;
}
//permission: Define object as readable by default
pobj[index].permission = &DMREAD;
json_object_object_foreach(jobj, key, json_obj) {
//bbfdm_type
if (strcmp(key, "protocols") == 0) {

View file

@ -1398,8 +1398,7 @@ static int mparam_get_schema_name(DMPARAM_ARGS)
* ***********************/
static int mobj_get_supported_dm(DMOBJECT_ARGS)
{
char *perm = permission->val;
char *perm = permission ? permission->val : "0";
char *refparam = node->current_object;
const char **unique_keys = NULL;
@ -1420,22 +1419,21 @@ static int mparam_get_supported_dm(DMPARAM_ARGS)
dmastrcat(&refparam, node->current_object, lastname);
if(node->matched) {
if(type == DMT_EVENT) {
if(dmctx->isevent) {
if (node->matched) {
if (type == DMT_EVENT) {
if (dmctx->isevent) {
if (get_cmd)
(get_cmd)(refparam, dmctx, data, instance, &value);
add_list_parameter(dmctx, refparam, value, DMT_TYPE[type], NULL);
}
} else if(type == DMT_COMMAND) {
} else if (type == DMT_COMMAND) {
if(dmctx->iscommand) {
if (get_cmd)
(get_cmd)(refparam, dmctx, data, instance, &value);
//add_list_parameter(dmctx, refparam, value, permission->val, NULL);
add_list_parameter(dmctx, refparam, value, DMT_TYPE[type], permission->val);
}
}