Repository: mdsteele/rust-ar (language: rust)

Issue:
crashes with empty GNU archive
```  
 0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic_new
             at /checkout/src/libstd/panicking.rs:553
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:521
   7: rust_begin_unwind
             at /checkout/src/libstd/panicking.rs:497
   8: core::panicking::panic_fmt
             at /checkout/src/libcore/panicking.rs:92
   9: core::panicking::panic_bounds_check
             at /checkout/src/libcore/panicking.rs:68
  10: <alloc::vec::Vec<T> as core::ops::index::Index<usize>>::index
             at /checkout/src/liballoc/vec.rs:1555
  11: <ar::Archive<R>>::parse_symbol_table_if_necessary
             at /home/aep/.cargo/git/checkouts/rust-ar-ab5156187b34e2fa/4831b8d/src/lib.rs:599
  12: <ar::Archive<R>>::symbols
             at /home/aep/.cargo/git/checkouts/rust-ar-ab5156187b34e2fa/4831b8d/src/lib.rs:609
  13: elfkit::loader::State::contains
             at src/loader.rs:92
  14: elfkit::loader::State::load_if::{{closure}}
             at src/loader.rs:80


```

[busybox.zip](https://github.com/mdsteele/rust-ar/files/1466266/busybox.zip)



Discussion / hints:

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index a926908..f9f8196 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -596,8 +596,10 @@ impl<R: Read + Seek> Archive<R> {
             self.symbol_table = Some(symbol_table);
         }
         // Resume our previous position in the file.
-        let offset = self.entry_headers[self.next_entry_index].1;
-        try!(self.reader.seek(SeekFrom::Start(offset)));
+        if self.entry_headers.len() > 0 {
+            let offset = self.entry_headers[self.next_entry_index].1;
+            try!(self.reader.seek(SeekFrom::Start(offset)));
+        }
         Ok(())
     }
 


Test patch: