fixes url completion segfaulting for empty strings (in case the user hasn't already started typing an URL)

Sat, 25 Aug 2018 15:12:38 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 25 Aug 2018 15:12:38 +0200
changeset 458
295eaa04fc41
parent 457
0eabb741d5d3
child 459
2c112cbaa08e

fixes url completion segfaulting for empty strings (in case the user hasn't already started typing an URL)

dav/main.c file | annotate | diff | comparison | revisions
--- a/dav/main.c	Sat Aug 25 14:41:02 2018 +0200
+++ b/dav/main.c	Sat Aug 25 15:12:38 2018 +0200
@@ -2069,7 +2069,9 @@
     if(!strcmp(cmd, "date")) {
         return 0;
     }
-    char *url = args->argv[3];
+
+    // get already typed URL or NULL, if the user hasn't started typing yet
+    char *url = args->argc > 3 ? args->argv[3] : NULL;
     
     //printf("index: {%s}\n", args->argv[0]);
     //printf("dav: {%s}\n", args->argv[1]);
@@ -2094,7 +2096,9 @@
 }
 
 int url_completion(char *u) {
-    sstr_t url = sstr(u);
+    sstr_t url;
+    url.ptr = u;
+    url.length = u ? strlen(u) : 0;
     
     // repo completion
     int repocomp = 1;

mercurial