Skip to content

Commit

Permalink
Don't crash if path passed to tr-create doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedld committed Jan 24, 2018
1 parent 3106675 commit 4b6529d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion libtransmission/makemeta.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,18 @@ static int builderFileCompare(void const* va, void const* vb)

tr_metainfo_builder* tr_metaInfoBuilderCreate(char const* topFileArg)
{
char* const real_top = tr_sys_path_resolve(topFileArg, NULL);

if (real_top == NULL)
{
/* TODO: Better error reporting */
return NULL;
}

struct FileList* files;
tr_metainfo_builder* ret = tr_new0(tr_metainfo_builder, 1);

ret->top = tr_sys_path_resolve(topFileArg, NULL);
ret->top = real_top;

{
tr_sys_path_info info;
Expand Down
6 changes: 6 additions & 0 deletions utils/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ int tr_main(int argc, char* argv[])

b = tr_metaInfoBuilderCreate(infile);

if (b == NULL)
{
fprintf(stderr, "ERROR: Cannot find specified input file or directory.\n");
return EXIT_FAILURE;
}

if (piecesize_kib != 0)
{
tr_metaInfoBuilderSetPieceSize(b, piecesize_kib * KiB);
Expand Down

0 comments on commit 4b6529d

Please sign in to comment.