if (archive_wstring_append_from_mbs(&temp_name, tmpdir,
strlen(tmpdir)) < 0)
goto exit_tmpfile;
- if (temp_name.s[temp_name.length-1] != L'/')
+ if (temp_name.length == 0 ||
+ temp_name.s[temp_name.length-1] != L'/')
archive_wstrappend_wchar(&temp_name, L'/');
}
tmp = "/tmp";
#endif
archive_strcpy(temppath, tmp);
- if (temppath->s[temppath->length-1] != '/')
+ if (temppath->length == 0 || temppath->s[temppath->length-1] != '/')
archive_strappend_char(temppath, '/');
return (ARCHIVE_OK);
}
goto exit_tmpfile;
} else {
archive_strcpy(&temp_name, tmpdir);
- if (temp_name.s[temp_name.length-1] != '/')
+ if (temp_name.length == 0 ||
+ temp_name.s[temp_name.length-1] != '/')
archive_strappend_char(&temp_name, '/');
}
#ifdef O_TMPFILE
goto exit_tmpfile;
} else
archive_strcpy(&temp_name, tmpdir);
- if (temp_name.s[temp_name.length-1] == '/') {
+ if (temp_name.length > 0 && temp_name.s[temp_name.length-1] == '/') {
temp_name.s[temp_name.length-1] = '\0';
temp_name.length --;
}