-Fixed some exceptions occurring when attempting to work with variables not expected to be None. Added the necessary checks

git-svn-id: http://pefile.googlecode.com/svn/trunk@106 8842bc4e-7134-0410-8230-5dc5194fb5c1
diff --git a/pefile.py b/pefile.py
index f898992..c5632fc 100644
--- a/pefile.py
+++ b/pefile.py
@@ -3226,6 +3226,11 @@
             
             symbol_name_address = self.get_dword_from_data(address_of_names, i)
 
+            if symbol_name_address is None:
+                max_failed_entries_before_giving_up -= 1
+                if max_failed_entries_before_giving_up <= 0:
+                    break
+                
             symbol_name = self.get_string_at_rva( symbol_name_address )
             try:
                 symbol_name_offset = self.get_offset_from_rva( symbol_name_address )
@@ -3239,7 +3244,7 @@
                 address_of_name_ordinals, i)
 
             
-            if symbol_ordinal*4 < len(address_of_functions):
+            if symbol_ordinal is not None and symbol_ordinal*4 < len(address_of_functions):
                 symbol_address = self.get_dword_from_data(
                     address_of_functions, symbol_ordinal)
             else:
@@ -3803,6 +3808,9 @@
     def get_string_at_rva(self, rva):
         """Get an ASCII string located at the given address."""
 
+        if rva is None:
+            return None
+
         s = self.get_section_by_rva(rva)
         if not s:
             return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])