Changeset 1141 for trunk/libtorrent/src/torrent/object_stream.cc
- Timestamp:
- 03/06/10 11:35:37 (2 years ago)
- Files:
-
- 1 modified
-
trunk/libtorrent/src/torrent/object_stream.cc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtorrent/src/torrent/object_stream.cc
r1140 r1141 39 39 #include <iterator> 40 40 #include <iostream> 41 #include <cmath> 42 #include <limits> 41 43 #include <rak/algorithm.h> 42 44 #include <rak/functional.h> … … 212 214 first = object_read_bencode_c_value(first + 1, last, object->as_value()); 213 215 214 if (first == NULL || first ==last || *first++ != 'e')216 if (first == last || *first++ != 'e') 215 217 break; 216 218 … … 224 226 *object = Object::create_list(); 225 227 226 while (first != NULL && first !=last) {228 while (first != last) { 227 229 if (*first == 'e') 228 230 return first + 1; … … 249 251 Object::string_type prev; 250 252 251 while (first != NULL && first !=last) {253 while (first != last) { 252 254 if (*first == 'e') 253 255 return first + 1; … … 348 350 first = object_read_bencode_skip_c(first, last); 349 351 350 if (first == NULL)351 return first;352 353 352 raw_bencode obj = raw_bencode(tmp, std::distance(tmp, first)); 354 353 355 if (obj.is_empty())356 return NULL;354 // if (obj.is_empty()) 355 // throw torrent::bencode_error("Invalid bencode data."); 357 356 358 357 switch (type) { … … 644 643 // sprintf(buffer, "Verified wrong, %u, '%u', '%s'.", std::distance(first, last), (unsigned int)*first, escaped.c_str()); 645 644 646 // throw torrent:: bencode_error("Invalid bencode data.");645 // throw torrent::internal_error("Invalid bencode data."); 647 646 // } 648 647 // } … … 657 656 char current_key[static_map_mapping_type::max_key_size + 2] = ""; 658 657 659 while (first != last && first != NULL) {658 while (first != last) { 660 659 // End a dictionary/list or the whole stream. 661 660 if (*first == 'e') { … … 666 665 667 666 stack_itr--; 667 continue; 668 668 } 669 669 … … 717 717 // The bencode object isn't a list. This should either skip it 718 718 // or produce an error. 719 if (*first++ != 'd') 720 throw torrent::bencode_error("Invalid bencode data."); 719 if (*first++ != 'd') { 720 first = object_read_bencode_skip_c(first - 1, last); 721 break; 722 } 721 723 722 724 stack_itr++; … … 734 736 // The bencode object isn't a list. This should either skip it 735 737 // or produce an error. 736 if (*first++ != 'l') 737 throw torrent::bencode_error("Invalid bencode data."); 738 if (*first++ != 'l') { 739 first = object_read_bencode_skip_c(first - 1, last); 740 break; 741 } 738 742 739 743 first_key = key_search.first; … … 746 750 747 751 if (first_key->key[key_search.second + 2] == '*') { 748 if ((first = object_read_bencode_raw_c(first, last, 749 &entry_values[first_key->index].object, 750 key_search.first->key[key_search.second + 1])) == NULL) 751 break; 752 first = object_read_bencode_raw_c(first, last, 753 &entry_values[first_key->index].object, 754 key_search.first->key[key_search.second + 1]); 752 755 } else { 753 if ((first = object_read_bencode_c(first, last, &entry_values[first_key->index].object)) == NULL) 754 break; 756 first = object_read_bencode_c(first, last, &entry_values[first_key->index].object); 755 757 } 756 758
