schema tree BUGFIX memory leak
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 084d527..1497a35 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -394,8 +394,7 @@
     case LYSC_PATH_LOG:
     case LYSC_PATH_DATA:
         for (iter = node; iter && (iter != parent) && (len >= 0); iter = iter->parent) {
-            char *s = buffer ? strdup(buffer) : path;
-            char *id;
+            char *s, *id;
             const char *slash;
 
             if ((pathtype == LYSC_PATH_DATA) && (iter->nodetype & (LYS_CHOICE | LYS_CASE))) {
@@ -403,6 +402,7 @@
                 continue;
             }
 
+            s = buffer ? strdup(buffer) : path;
             id = strdup(iter->name);
             if (parent && (iter->parent == parent)) {
                 slash = "";