bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit


From: Cristian Baboi
Subject: Re: gettext-0.16.1: file vasprintf.c is wrong on amd64 bit
Date: Tue, 25 Sep 2007 09:25:35 +0300
User-agent: Opera Mail/9.23 (Win32)

On Tue, 25 Sep 2007 02:45:00 +0300, Andreas Schwab <address@hidden> wrote:

Bruno Haible <address@hidden> writes:

*** lib/vasprintf.c     13 May 2007 23:06:17 -0000      1.3
--- lib/vasprintf.c     24 Sep 2007 23:02:46 -0000
***************
*** 38,45 ****
    /* Add one to make sure that it is never zero, which might cause
malloc
       to return NULL.  */
    size_t total_width = strlen (format) + 1;
!   va_list ap = *args;

    while (*p != '\0')
      {
        if (*p++ == '%')
--- 38,46 ----
    /* Add one to make sure that it is never zero, which might cause
malloc
       to return NULL.  */
    size_t total_width = strlen (format) + 1;
!   va_list ap;

+   va_copy (ap, *args);

If you call va_copy, you must also call va_end (also missing from
checkit).

Andreas.

This time is better ?



--- gettext-0.16.1/gettext-tools/gnulib-lib/vasprintf.c 2006-11-27
19:14:53.000000000 +0200
+++ vasprintf.c 2007-09-25 09:21:53.000000000 +0300
@@ -38,7 +38,8 @@
   /* Add one to make sure that it is never zero, which might cause malloc
      to return NULL.  */
   size_t total_width = strlen (format) + 1;
-  va_list ap = *args;
+  va_list ap ;
+  va_copy(ap,*args);

   while (*p != '\0')
     {
@@ -110,7 +111,8 @@
 #ifdef TEST
   global_total_width = total_width;
 #endif
-  *result = malloc (total_width);
+  va_end(ap);
+  *result = (char *) malloc (total_width);
   if (*result != NULL)
     return vsprintf (*result, format, *args);
   else
@@ -120,7 +122,12 @@
 int
 vasprintf (char **result, const char *format, va_list args)
 {
-  return int_vasprintf (result, format, &args);
+  int rez;
+  va_list ap;
+  va_copy(ap,args);
+  rez= int_vasprintf (result, format, &ap);
+  va_end(ap);
+  return rez;
 }

 int
@@ -155,6 +162,7 @@
   else
     printf ("FAIL: ");
   printf ("%lu %s\n", (unsigned long) global_total_width, result);
+  va_end(args);
 }

 int


-------------------------------------------------------------
This mail was scanned by BitDefender
For more informations please visit http://www.bitdefender.com


------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]