@@ -872,21 +872,21 @@ int archprintf(Archive* AH, const char *fmt, ...)
872
872
int bSize = strlen (fmt ) + 256 ;
873
873
int cnt = -1 ;
874
874
875
- va_start (ap , fmt );
876
-
877
875
/* This is paranoid: deal with the possibility that vsnprintf is willing to ignore trailing null */
878
876
/* or returns > 0 even if string does not fit. It may be the case that it returns cnt = bufsize */
879
- while (cnt < 0 || cnt >= (bSize - 1 ) ) {
880
- if (p != NULL ) free (p );
881
- bSize *= 2 ;
882
- if ((p = malloc (bSize )) == NULL )
877
+ while (cnt < 0 || cnt >= (bSize - 1 ) )
883
878
{
884
- va_end (ap );
885
- exit_horribly (AH , "%s: could not allocate buffer for archprintf\n" , progname );
886
- }
887
- cnt = vsnprintf (p , bSize , fmt , ap );
879
+ if (p != NULL ) free (p );
880
+ bSize *= 2 ;
881
+ p = (char * )malloc (bSize );
882
+ if (p == NULL )
883
+ {
884
+ exit_horribly (AH , "%s: could not allocate buffer for archprintf\n" , progname );
885
+ }
886
+ va_start (ap , fmt );
887
+ cnt = vsnprintf (p , bSize , fmt , ap );
888
+ va_end (ap );
888
889
}
889
- va_end (ap );
890
890
WriteData (AH , p , cnt );
891
891
free (p );
892
892
return cnt ;
@@ -977,21 +977,21 @@ int ahprintf(ArchiveHandle* AH, const char *fmt, ...)
977
977
int bSize = strlen (fmt ) + 256 ; /* Should be enough */
978
978
int cnt = -1 ;
979
979
980
- va_start (ap , fmt );
981
980
/* This is paranoid: deal with the possibility that vsnprintf is willing to ignore trailing null */
982
981
/* or returns > 0 even if string does not fit. It may be the case that it returns cnt = bufsize */
983
- while (cnt < 0 || cnt >= (bSize - 1 ) ) {
982
+ while (cnt < 0 || cnt >= (bSize - 1 ) )
983
+ {
984
984
if (p != NULL ) free (p );
985
985
bSize *= 2 ;
986
986
p = (char * )malloc (bSize );
987
987
if (p == NULL )
988
988
{
989
- va_end (ap );
990
989
die_horribly (AH , "%s: could not allocate buffer for ahprintf\n" , progname );
991
990
}
991
+ va_start (ap , fmt );
992
992
cnt = vsnprintf (p , bSize , fmt , ap );
993
+ va_end (ap );
993
994
}
994
- va_end (ap );
995
995
ahwrite (p , 1 , cnt , AH );
996
996
free (p );
997
997
return cnt ;
0 commit comments