<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tests/data/out-of-range.exif</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -492,7 +492,8 @@ module EXIFR
 
         if len &amp;&amp; pack &amp;&amp; @type != 7
           start = len &gt; 4 ? @offset : (pos + 8)
-          @value = [pack[data[start..(start + len - 1)]]].flatten
+          d = data[start..(start + len - 1)]
+          @value = d &amp;&amp; [pack[d]].flatten
         end
       end
     end
@@ -521,7 +522,7 @@ module EXIFR
           read_for(pos)
         end
 
-        @buffer[(pos.begin - @pos)..(pos.end - @pos)]
+        @buffer &amp;&amp; @buffer[(pos.begin - @pos)..(pos.end - @pos)]
       end
 
       def readshort(pos)</diff>
      <filename>lib/tiff.rb</filename>
    </modified>
    <modified>
      <diff>@@ -91,7 +91,7 @@ class TIFFTest &lt; Test::Unit::TestCase
     assert_equal [678886.quo(100000), 0.quo(1), 0.quo(1)], t.gps_longitude
     assert_equal 'WGS84', t.gps_map_datum
 
-    (all_test_exifs - [f('gps.exif'), f('user-comment.exif')]).each do |fname|
+    (all_test_exifs - %w(gps user-comment out-of-range).map{|v| f(&quot;#{v}.exif&quot;)}).each do |fname|
       assert_nil TIFF.new(fname).gps_version_id
     end
   end
@@ -166,4 +166,10 @@ class TIFFTest &lt; Test::Unit::TestCase
   def test_user_comment
     assert_equal &quot;Manassas Battlefield&quot;, TIFF.new(f('user-comment.exif')).user_comment
   end
+  
+  def test_handle_out_of_range_offset
+    assert_nothing_raised do
+      assert 'NIKON', TIFF.new(f('out-of-range.exif')).make
+    end
+  end
 end</diff>
      <filename>tests/tiff_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>127c5b1c3fca359aa6480afc32b3ec9ccddac68c</id>
    </parent>
  </parents>
  <author>
    <name>Remco van 't Veer</name>
    <email>rwvtveer@xs4all.nl</email>
  </author>
  <url>http://github.com/remvee/exifr/commit/7153cb86c1d60e20ca14372bd1507096c1a7e99d</url>
  <id>7153cb86c1d60e20ca14372bd1507096c1a7e99d</id>
  <committed-date>2009-11-10T12:15:39-08:00</committed-date>
  <authored-date>2009-11-10T12:15:39-08:00</authored-date>
  <message>GH issue #2 &quot;Nil pointer in tiff.rb&quot;

Handle bad IFD record with offset out of range</message>
  <tree>79bd5248aa05e6777fe989a538ef24fa411d5058</tree>
  <committer>
    <name>Remco van 't Veer</name>
    <email>rwvtveer@xs4all.nl</email>
  </committer>
</commit>
