data helpers BUGFIX check input
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index e1eadf8..22c1899 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -259,6 +259,8 @@
 API const char *
 lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value)
 {
+    LY_CHECK_ARG_RET(ctx, ctx, value, NULL);
+
     return value->_canonical ? value->_canonical :
            (const char *)value->realtype->plugin->print(ctx, value, LY_VALUE_CANON, NULL, NULL, NULL);
 }