tree schema UPDATE check for buffer overflow
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 1ac76bc..1f9fd69 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -762,8 +762,12 @@
                 } else {
                     len = asprintf(&path, "[%s='%%s']%s", key->name, s ? s : "");
                 }
-
                 free(s);
+
+                if (buffer && (buflen <= (size_t)len)) {
+                    /* not enough space in buffer */
+                    break;
+                }
             }
         }