]> granicus.if.org Git - curl/commitdiff
Test if type casting a 'signed int' to a 'signed long long' fails to do sign extensio...
authorYang Tse <yangsita@gmail.com>
Sun, 24 Aug 2008 00:15:59 +0000 (00:15 +0000)
committerYang Tse <yangsita@gmail.com>
Sun, 24 Aug 2008 00:15:59 +0000 (00:15 +0000)
lib/mprintf.c

index be6832fa132df534648115683654b8276831138c..3a83cf0011b345d2639f09c02f097ca31ead93a4 100644 (file)
@@ -325,6 +325,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
   int flags;
   long max_param=0;
   long i;
+  int aux_signed_int;
 
   while(*fmt) {
     if(*fmt++ == '%') {
@@ -591,9 +592,17 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
           else if(vto[i].flags & FLAGS_UNSIGNED)
             vto[i].data.num.as_unsigned =
               (mp_uintmax_t)va_arg(arglist, unsigned int);
-          else
+          else {
+            /*
             vto[i].data.num.as_signed =
               (mp_intmax_t)va_arg(arglist, int);
+            */
+            aux_signed_int = va_arg(arglist, int);
+            if(sizeof(mp_intmax_t) > sizeof(long))
+              vto[i].data.num.as_signed = (mp_intmax_t)aux_signed_int;
+            else
+              vto[i].data.num.as_signed = (long)aux_signed_int;
+          }
         }
         break;