commit 06b3770e6e03eae10b4b21cf8a9d7a6e7e490d3b
parent b22c37edddce3b80e31902b57057b6db36452df6
Author: Santtu Lakkala <inz@inz.fi>
Date: Sun, 16 May 2021 00:53:58 +0300
Fix gph root-relative links
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
@@ -289,7 +289,12 @@ static bool tryfileat(int *fd, const char *fn)
static char *joinstr(const char *a, const char *b, char separator)
{
- char *rv = malloc(strlen(a) + strlen(b) + 2);
+ char *rv;
+ if (!a || !*a)
+ return strdup(b);
+ if (!b || !*b)
+ return strdup(a);
+ rv = malloc(strlen(a) + strlen(b) + 2);
sprintf(rv, "%s%c%s", a, separator, b);
return rv;
}