@@ -872,21 +872,21 @@ int archprintf(Archive* AH, const char *fmt, ...)
872872int bSize = strlen (fmt )+ 256 ;
873873int cnt = -1 ;
874874
875- va_start (ap ,fmt );
876-
877875/* This is paranoid: deal with the possibility that vsnprintf is willing to ignore trailing null */
878876/* 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 ) )
883878{
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 );
888889 }
889- va_end (ap );
890890WriteData (AH ,p ,cnt );
891891free (p );
892892return cnt ;
@@ -977,21 +977,21 @@ int ahprintf(ArchiveHandle* AH, const char *fmt, ...)
977977int bSize = strlen (fmt )+ 256 ;/* Should be enough */
978978int cnt = -1 ;
979979
980- va_start (ap ,fmt );
981980/* This is paranoid: deal with the possibility that vsnprintf is willing to ignore trailing null */
982981/* 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+ {
984984if (p != NULL )free (p );
985985bSize *=2 ;
986986p = (char * )malloc (bSize );
987987if (p == NULL )
988988{
989- va_end (ap );
990989die_horribly (AH ,"%s: could not allocate buffer for ahprintf\n" ,progname );
991990}
991+ va_start (ap ,fmt );
992992cnt = vsnprintf (p ,bSize ,fmt ,ap );
993+ va_end (ap );
993994 }
994- va_end (ap );
995995ahwrite (p ,1 ,cnt ,AH );
996996free (p );
997997return cnt ;