@@ -405,7 +405,12 @@ namespace {
405405#ifndef BOOST_NO_EXCEPTIONS
406406 torrent_handle session_handle::add_torrent (add_torrent_params&& params)
407407 {
408+ #ifndef BOOST_NO_EXCEPTIONS
409+ if (params.save_path .empty ())
410+ aux::throw_ex<system_error>(error_code (errors::invalid_save_path));
411+ #else
408412 TORRENT_ASSERT_PRECOND (!params.save_path .empty ());
413+ #endif
409414
410415#if TORRENT_ABI_VERSION < 3
411416 if (!params.info_hashes .has_v1 () && !params.info_hashes .has_v2 () && !params.ti )
@@ -435,7 +440,11 @@ namespace {
435440
436441 torrent_handle session_handle::add_torrent (add_torrent_params&& params, error_code& ec)
437442 {
438- TORRENT_ASSERT_PRECOND (!params.save_path .empty ());
443+ if (params.save_path .empty ())
444+ {
445+ ec = error_code (errors::invalid_save_path);
446+ return {};
447+ }
439448
440449#if TORRENT_ABI_VERSION < 3
441450 if (!params.info_hashes .has_v1 () && !params.info_hashes .has_v2 () && !params.ti )
@@ -467,7 +476,12 @@ namespace {
467476
468477 void session_handle::async_add_torrent (add_torrent_params&& params)
469478 {
479+ #ifndef BOOST_NO_EXCEPTIONS
480+ if (params.save_path .empty ())
481+ aux::throw_ex<system_error>(error_code (errors::invalid_save_path));
482+ #else
470483 TORRENT_ASSERT_PRECOND (!params.save_path .empty ());
484+ #endif
471485
472486#if TORRENT_ABI_VERSION < 3
473487 if (!params.info_hashes .has_v1 () && !params.info_hashes .has_v2 () && !params.ti )
@@ -528,7 +542,12 @@ namespace {
528542 , bool const add_paused
529543 , client_data_t userdata)
530544 {
545+ #ifndef BOOST_NO_EXCEPTIONS
546+ if (save_path.empty ())
547+ aux::throw_ex<system_error>(error_code (errors::invalid_save_path));
548+ #else
531549 TORRENT_ASSERT_PRECOND (!save_path.empty ());
550+ #endif
532551
533552 add_torrent_params p;
534553 p.trackers .push_back (tracker_url);
0 commit comments