Don't segfault if xabspath() returns null (spotted by Taolaw).

This commit is contained in:
Rob Landley 2022-05-29 06:19:30 -05:00
parent 20c123b95d
commit 6d4847934f

View File

@ -83,7 +83,7 @@ char *mime(char *file)
static int isunder(char *file, char *dir)
{
char *s1 = xabspath(dir, ABS_FILE), *s2 = xabspath(file, 0), *ss = s2;
int rc = strstart(&ss, s2) && (!*ss || *ss=='/' || ss[-1]=='/');
int rc = s1 && s2 && strstart(&ss, s1) && (!*ss || *ss=='/' || ss[-1]=='/');
free(s2);
free(s1);