Handle potential dirname/basename errors where needed

This commit is contained in:
Mike Gelfand
2016-03-13 10:41:52 +00:00
parent 5569efc3d4
commit 91f8ceb20d
7 changed files with 78 additions and 24 deletions
+8 -1
View File
@@ -156,7 +156,14 @@ tr_main (int argc,
if (outfile == NULL)
{
char * base = tr_sys_path_basename (infile, NULL);
tr_error * error = NULL;
char * base = tr_sys_path_basename (infile, &error);
if (base == NULL)
{
fprintf (stderr, "ERROR: Cannot deduce output path from input path: %s\n", error->message);
return EXIT_FAILURE;
}
char * end = tr_strdup_printf ("%s.torrent", base);
char * cwd = tr_getcwd ();
outfile = out2 = tr_buildPath (cwd, end, NULL);