@@ -187,7 +187,7 @@ func (r *Reader) newObject() (core.Object, error) {
187187 return raw , err
188188}
189189
190- func (r * Reader ) readREFDelta (raw core.Object ) error {
190+ func (r * Reader ) readREFDelta (raw core.Object ) ( err error ) {
191191 var ref core.Hash
192192 if _ , err := io .ReadFull (r .r , ref [:]); err != nil {
193193 return err
@@ -206,28 +206,45 @@ func (r *Reader) readREFDelta(raw core.Object) error {
206206 return err
207207 }
208208
209- d , _ := ioutil .ReadAll (referenced .Reader ())
209+ reader , err := referenced .Reader ()
210+ if err != nil {
211+ return err
212+ }
213+ defer close (reader , & err )
214+
215+ d , err := ioutil .ReadAll (reader )
216+ if err != nil {
217+ return err
218+ }
219+
210220 patched := patchDelta (d , buf .Bytes ())
211221 if patched == nil {
212222 return PatchingErr .n ("hash %q" , ref )
213223 }
214224
215225 raw .SetType (referenced .Type ())
216226 raw .SetSize (int64 (len (patched )))
217- raw .Writer ().Write (patched )
227+
228+ writer , err := raw .Writer ()
229+ if err != nil {
230+ return err
231+ }
232+ defer close (writer , & err )
233+
234+ writer .Write (patched )
218235
219236 return nil
220237}
221238
222- func (r * Reader ) readOFSDelta (raw core.Object , steps int64 ) error {
239+ func (r * Reader ) readOFSDelta (raw core.Object , steps int64 ) ( err error ) {
223240 start := r .r .position
224241 offset , err := decodeOffset (r .r , steps )
225242 if err != nil {
226243 return err
227244 }
228245
229246 buf := bytes .NewBuffer (nil )
230- if err : = r .inflate (buf ); err != nil {
247+ if err = r .inflate (buf ); err != nil {
231248 return err
232249 }
233250
@@ -236,22 +253,49 @@ func (r *Reader) readOFSDelta(raw core.Object, steps int64) error {
236253 return PackEntryNotFoundErr .n ("offset %d" , start + offset )
237254 }
238255
239- referenced , _ := r .s .Get (ref ) // FIXME: Handle error returned from Get()
240- d , _ := ioutil .ReadAll (referenced .Reader ())
256+ referenced , err := r .s .Get (ref )
257+ if err != nil {
258+ return err
259+ }
260+
261+ reader , err := referenced .Reader ()
262+ if err != nil {
263+ return err
264+ }
265+ defer close (reader , & err )
266+
267+ d , err := ioutil .ReadAll (reader )
268+ if err != nil {
269+ return err
270+ }
271+
241272 patched := patchDelta (d , buf .Bytes ())
242273 if patched == nil {
243274 return PatchingErr .n ("hash %q" , ref )
244275 }
245276
246277 raw .SetType (referenced .Type ())
247278 raw .SetSize (int64 (len (patched )))
248- raw .Writer ().Write (patched )
279+
280+ writer , err := raw .Writer ()
281+ if err != nil {
282+ return err
283+ }
284+ defer close (writer , & err )
285+
286+ writer .Write (patched )
249287
250288 return nil
251289}
252290
253- func (r * Reader ) readObject (raw core.Object ) error {
254- return r .inflate (raw .Writer ())
291+ func (r * Reader ) readObject (raw core.Object ) (err error ) {
292+ writer , err := raw .Writer ()
293+ if err != nil {
294+ return err
295+ }
296+ defer close (writer , & err )
297+
298+ return r .inflate (writer )
255299}
256300
257301func (r * Reader ) inflate (w io.Writer ) error {
0 commit comments