parser json BUGFIX invalid dereference
diff --git a/src/parser_json.c b/src/parser_json.c
index d5adde4..83a0bde 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -1146,7 +1146,7 @@
enum LYJSON_PARSER_STATUS *status_p, struct lyd_node **first_p, struct lyd_node **node_p)
{
LY_ERR r;
- const char *opaq_name;
+ const char *opaq_name, *mod_name;
size_t opaq_name_len;
if (!snode && !prefix) {
@@ -1169,8 +1169,8 @@
break;
}
} else {
- if (!strcmp(LYD_NAME(attr_node), snode->name) &&
- !strcmp(((struct lyd_node_opaq *)attr_node)->name.module_name, snode->module->name)) {
+ mod_name = ((struct lyd_node_opaq *)attr_node)->name.module_name;
+ if (!strcmp(LYD_NAME(attr_node), snode->name) && mod_name && !strcmp(mod_name, snode->module->name)) {
break;
}
}
@@ -1181,8 +1181,9 @@
break;
}
} else {
- if (!ly_strncmp(LYD_NAME(attr_node), name, name_len) &&
- !ly_strncmp(((struct lyd_node_opaq *)attr_node)->name.module_name, prefix, prefix_len)) {
+ mod_name = ((struct lyd_node_opaq *)attr_node)->name.module_name;
+ if (!ly_strncmp(LYD_NAME(attr_node), name, name_len) && mod_name &&
+ !ly_strncmp(mod_name, prefix, prefix_len)) {
break;
}
}