tree schema BUGFIX memory leak in lysc_path()
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 61ca70e..d828c67 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -225,6 +225,11 @@
     char *path = NULL;
     int len = 0;
 
+    LY_CHECK_ARG_RET(NULL, node, NULL);
+    if (buffer) {
+        LY_CHECK_ARG_RET(node->module->ctx, buflen > 1, NULL);
+    }
+
     switch (pathtype) {
     case LY_PATH_LOG:
         for (iter = node; iter && len >= 0; iter = iter->parent) {
@@ -274,8 +279,11 @@
             free(path);
             path = NULL;
         } else if (len == 0) {
-            path = strdup("/");
-            len = 1;
+            if (buffer) {
+                strcpy(buffer, "/");
+            } else {
+                path = strdup("/");
+            }
         }
         break;
     }