tree schema BUGFIX unknown extension instance free coredump
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 790b89f..2471de0 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -467,7 +467,7 @@
 void
 lysc_ext_instance_free(struct ly_ctx *ctx, struct lysc_ext_instance *ext)
 {
-    if (ext->def->plugin && ext->def->plugin->free) {
+    if (ext->def && ext->def->plugin && ext->def->plugin->free) {
         ext->def->plugin->free(ctx, ext);
     }
     FREE_STRING(ctx, ext->argument);