]> git.sur5r.net Git - i3/i3/blobdiff - libi3/resolve_tilde.c
Merge pull request #1985 from Airblader/bug-1984
[i3/i3] / libi3 / resolve_tilde.c
index 3a56cbea853495a56a6646d3e13a6ecc52fcb167..7a4fb79bf3c2ddca62b9b9bf07a532f96c867f58 100644 (file)
@@ -23,7 +23,7 @@ char *resolve_tilde(const char *path) {
     char *head, *tail, *result;
 
     tail = strchr(path, '/');
-    head = strndup(path, tail ? (size_t)(tail - path) : strlen(path));
+    head = sstrndup(path, tail ? (size_t)(tail - path) : strlen(path));
 
     int res = glob(head, GLOB_TILDE, NULL, &globbuf);
     free(head);
@@ -34,7 +34,7 @@ char *resolve_tilde(const char *path) {
         err(EXIT_FAILURE, "glob() failed");
     } else {
         head = globbuf.gl_pathv[0];
-        result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1);
+        result = scalloc(strlen(head) + (tail ? strlen(tail) : 0) + 1, 1);
         strncpy(result, head, strlen(head));
         if (tail)
             strncat(result, tail, strlen(tail));