From f776cbbc467c5369e34f4cb4a3fada5fb78bdfae Mon Sep 17 00:00:00 2001 From: Kevin Lynx Date: Thu, 11 Jul 2013 09:05:54 +0800 Subject: [PATCH] torbuilder(importer) fix badarith bug when there're invalid name torrent files --- src/tor_builder/tor_location_writer.erl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tor_builder/tor_location_writer.erl b/src/tor_builder/tor_location_writer.erl index d93a5fe..20fbe63 100644 --- a/src/tor_builder/tor_location_writer.erl +++ b/src/tor_builder/tor_location_writer.erl @@ -94,13 +94,15 @@ parse_hash(FileName) -> append_torrent_names(FP, [Name|Rest]) -> Hash = parse_hash(Name), - case length(Hash) == 40 of + This = case length(Hash) == 40 of true -> - io:format(FP, "~s~n", [Name]) , - 1 + append_torrent_names(FP, Rest); + io:format(FP, "~s~n", [Name]), + 1; false -> - ?W(?FMT("invalid torrent file name ~s", [Name])) - end; + ?W(?FMT("invalid torrent file name ~s", [Name])), + 0 + end, + This + append_torrent_names(FP, Rest); append_torrent_names(_, []) -> 0.