From 1a927787b1d42c89fc603ccac03e9cccb3600651 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 2 Jun 2011 22:15:42 +0000 Subject: [PATCH] distinguish between an empty name and missing name in torrent files --- src/torrent_info.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 4da04af54..93fdc5e2e 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -779,14 +779,15 @@ namespace libtorrent m_files.set_piece_length(piece_length); // extract file name (or the directory name if it's a multifile libtorrent) - std::string name = info.dict_find_string_value("name.utf-8"); - if (name.empty()) name = info.dict_find_string_value("name"); - if (name.empty()) + lazy_entry const* name_ent = info.dict_find_string("name.utf-8"); + if (name_ent == 0) name_ent = info.dict_find_string("name"); + if (name_ent == 0) { ec = errors::torrent_missing_name; return false; } + std::string name = name_ent->string_value(); name = sanitize_path(name); if (!valid_path_element(name))