libidav/resource.c

changeset 280
6d8784bee427
parent 269
c89633916e36
child 298
755b8198b071
--- a/libidav/resource.c	Sat Aug 05 10:57:47 2017 +0200
+++ b/libidav/resource.c	Sat Aug 05 11:08:34 2017 +0200
@@ -81,11 +81,13 @@
 DavResource* dav_resource_new_full(DavSession *sn, char *parent_path, char *name, char *href) {
     sstr_t n = sstr(name);
     // the name must not contain path separators
-    for(int i=0;i<n.length-1;i++) {
-        char c = n.ptr[i];
-        if(c == '/' || c == '\\') {
-            n = sstr(util_resource_name(href));
-            break;
+    if(n.length > 0) {
+        for(int i=0;i<n.length-1;i++) {
+            char c = n.ptr[i];
+            if(c == '/' || c == '\\') {
+                n = sstr(util_resource_name(href));
+                break;
+            }
         }
     }
     // remove trailing '/'

mercurial