@@ -488,13 +488,11 @@ int git_packfile_resolve_header(
488488 size_t base_size ;
489489 git_packfile_stream stream ;
490490
491- base_offset = get_delta_base (p , & w_curs , & curpos , type , offset );
491+ error = get_delta_base (& base_offset , p , & w_curs , & curpos , type , offset );
492492 git_mwindow_close (& w_curs );
493493
494- if (base_offset < 0 ) {
495- error = (int )base_offset ;
494+ if (error < 0 )
496495 return error ;
497- }
498496
499497 if ((error = git_packfile_stream_open (& stream , p , curpos )) < 0 )
500498 return error ;
@@ -515,13 +513,11 @@ int git_packfile_resolve_header(
515513 if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA )
516514 break ;
517515
518- base_offset = get_delta_base (p , & w_curs , & curpos , type , base_offset );
516+ error = get_delta_base (& base_offset , p , & w_curs , & curpos , type , base_offset );
519517 git_mwindow_close (& w_curs );
520518
521- if (base_offset < 0 ) {
522- error = (int )base_offset ;
519+ if (error < 0 )
523520 return error ;
524- }
525521 }
526522 * type_p = type ;
527523
@@ -595,13 +591,11 @@ static int pack_dependency_chain(git_dependency_chain *chain_out,
595591 if (type != GIT_OBJECT_OFS_DELTA && type != GIT_OBJECT_REF_DELTA )
596592 break ;
597593
598- base_offset = get_delta_base (p , & w_curs , & curpos , type , obj_offset );
594+ error = get_delta_base (& base_offset , p , & w_curs , & curpos , type , obj_offset );
599595 git_mwindow_close (& w_curs );
600596
601- if (base_offset < 0 ) { /* must actually be an error code */
602- error = (int )base_offset ;
597+ if (error < 0 )
603598 goto on_error ;
604- }
605599
606600 /* we need to pass the pos *after* the delta-base bit */
607601 elem -> offset = curpos ;
@@ -886,18 +880,21 @@ static int packfile_unpack_compressed(
886880 * curpos is where the data starts, delta_obj_offset is the where the
887881 * header starts
888882 */
889- off64_t get_delta_base (
890- struct git_pack_file * p ,
891- git_mwindow * * w_curs ,
892- off64_t * curpos ,
893- git_object_t type ,
894- off64_t delta_obj_offset )
883+ int get_delta_base (
884+ off64_t * delta_base_out ,
885+ struct git_pack_file * p ,
886+ git_mwindow * * w_curs ,
887+ off64_t * curpos ,
888+ git_object_t type ,
889+ off64_t delta_obj_offset )
895890{
896891 unsigned int left = 0 ;
897892 unsigned char * base_info ;
898893 off64_t base_offset ;
899894 git_oid unused ;
900895
896+ assert (delta_base_out );
897+
901898 base_info = pack_window_open (p , w_curs , * curpos , & left );
902899 /* Assumption: the only reason this would fail is because the file is too small */
903900 if (base_info == NULL )
@@ -934,7 +931,8 @@ off64_t get_delta_base(
934931 git_oid_fromraw (& oid , base_info );
935932 if ((entry = git_oidmap_get (p -> idx_cache , & oid )) != NULL ) {
936933 * curpos += 20 ;
937- return entry -> offset ;
934+ * delta_base_out = entry -> offset ;
935+ return 0 ;
938936 } else {
939937 /* If we're building an index, don't try to find the pack
940938 * entry; we just haven't seen it yet. We'll make
@@ -951,7 +949,8 @@ off64_t get_delta_base(
951949 } else
952950 return packfile_error ("unknown object type" );
953951
954- return base_offset ;
952+ * delta_base_out = base_offset ;
953+ return 0 ;
955954}
956955
957956/***********************************************************
0 commit comments