fixes dav_resource_new_full

Sat, 05 Aug 2017 11:08:34 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 05 Aug 2017 11:08:34 +0200
changeset 280
6d8784bee427
parent 279
f0f24da5f920
child 281
ddb5e8f2a43d

fixes dav_resource_new_full

libidav/resource.c file | annotate | diff | comparison | revisions
--- 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