Browse Source

FIx off-by-one error, and thinko.

James Westby 16 years ago
parent
commit
e0411696e2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      dulwich/pack.py

+ 2 - 2
dulwich/pack.py

@@ -747,12 +747,12 @@ def apply_delta(src_buf, delta):
                 break
                 break
             out += src_buf[cp_off:cp_off+cp_size]
             out += src_buf[cp_off:cp_off+cp_size]
         elif cmd != 0:
         elif cmd != 0:
-            out += delta[index:cmd]
+            out += delta[index:index+cmd]
             index += cmd
             index += cmd
         else:
         else:
             raise ApplyDeltaError("Invalid opcode 0")
             raise ApplyDeltaError("Invalid opcode 0")
     
     
-    if index != delta_length - 1:
+    if index != delta_length:
         raise ApplyDeltaError("delta not empty: %r" % delta[index:])
         raise ApplyDeltaError("delta not empty: %r" % delta[index:])
 
 
     if dest_size != len(out):
     if dest_size != len(out):