merge from open-source master
authorThe Android Open Source Project <initial-contribution@android.com>
Mon, 3 May 2010 22:33:05 +0000 (15:33 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Mon, 3 May 2010 22:33:05 +0000 (15:33 -0700)
Change-Id: If02d33af51017dbd85e91c79ac2e848eda6cf253

1  2 
libc/bionic/logd_write.c
libc/bionic/malloc_debug_leak.c
libc/stdlib/strtod.c
libc/stdlib/wchar.c

index 2c5bf42f34f18ac8d199a21617d4162c5d21db47,39f02588ed425bd6cc18b6fc13a85700e2ebdfdb..618160faa7a313c46ad21d4e649e49f0f267fd87
@@@ -112,8 -112,9 +112,10 @@@ static int __write_to_log_init(log_id_
  
          log_channels[log_id].logger =
              (fd < 0) ? __write_to_log_null : __write_to_log_kernel;
 +        log_channels[log_id].fd = fd;
  
+         log_channels[log_id].fd = fd;
          pthread_mutex_unlock(&log_init_lock);
  
          return log_channels[log_id].logger(log_id, vec);
Simple merge
index b1f5868c3ecf31e7bdc52986a7ff1514468a2d06,d2582b1ebfc6ec0a19cb751fb5b83bdc914b0220..9d599b05993a4e846bd2929dfadbe915a5f6ca22
@@@ -415,15 -397,11 +415,15 @@@ Ballo
        else {
                x = 1 << k;
                rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
 +              if (rv == NULL) {
 +                      rv = BIGINT_INVALID;
 +                      goto EXIT;
 +              }
                rv->k = k;
                rv->maxwds = x;
-               }
+       }
        rv->sign = rv->wds = 0;
 -
 +EXIT:
        mutex_unlock(&freelist_mutex);
  
        return rv;
@@@ -444,26 -422,11 +444,26 @@@ Bfre
                freelist[v->k] = v;
  
                mutex_unlock(&freelist_mutex);
-               }
        }
+ }
  
 -#define Bcopy(x,y) memcpy(&x->sign, &y->sign, \
 -    y->wds*sizeof(Long) + 2*sizeof(int))
 +#define Bcopy_valid(x,y) memcpy(&(x)->sign, &(y)->sign, \
 +    (y)->wds*sizeof(Long) + 2*sizeof(int))
 +
 +#define Bcopy(x,y)  Bcopy_ptr(&(x),(y))
 +
 + static void
 +Bcopy_ptr(Bigint **px, Bigint *y)
 +{
 +      if (*px == BIGINT_INVALID)
 +              return; /* no space to store copy */
 +      if (y == BIGINT_INVALID) {
 +              Bfree(*px); /* invalid input */
 +              *px = BIGINT_INVALID;
 +      } else {
 +              Bcopy_valid(*px,y);
 +      }
 +}
  
   static Bigint *
  multadd
@@@ -653,12 -604,10 +653,12 @@@ i2
        Bigint *b;
  
        b = Balloc(1);
 -      b->x[0] = i;
 -      b->wds = 1;
 +      if (b != BIGINT_INVALID) {
 +              b->x[0] = i;
 +              b->wds = 1;
 +              }
        return b;
      }
+ }
  
   static Bigint *
  mult
@@@ -777,14 -718,9 +777,14 @@@ pow5mul
                return b;
        if (!(p5 = p5s)) {
                /* first time */
 -              p5 = p5s = i2b(625);
 +              p5 = i2b(625);
 +              if (p5 == BIGINT_INVALID) {
 +                      Bfree(b);
 +                      return p5;
 +              }
 +              p5s = p5;
                p5->next = 0;
-               }
+       }
        for(;;) {
                if (k & 1) {
                        b1 = mult(b, p5);
                if (!(k = (unsigned int) k >> 1))
                        break;
                if (!(p51 = p5->next)) {
 -                      p51 = p5->next = mult(p5,p5);
 +                      p51 = mult(p5,p5);
 +                      if (p51 == BIGINT_INVALID) {
 +                              Bfree(b);
 +                              return p51;
 +                      }
 +                      p5->next = p51;
                        p51->next = 0;
-                       }
-               p5 = p51;
                }
-       return b;
+               p5 = p51;
        }
+       return b;
+ }
  
   static Bigint *
  lshift
@@@ -937,12 -851,10 +937,12 @@@ dif
        i = cmp(a,b);
        if (!i) {
                c = Balloc(0);
 -              c->wds = 1;
 -              c->x[0] = 0;
 +              if (c != BIGINT_INVALID) {
 +                      c->wds = 1;
 +                      c->x[0] = 0;
 +                      }
                return c;
-               }
+       }
        if (i < 0) {
                c = a;
                a = b;
@@@ -2167,14 -2063,12 +2166,14 @@@ __dto
        if (!value(d)) {
                *decpt = 1;
                result = Balloc(2);
-               s0 = (char *)(void *)result;
-               strcpy(s0, "0");
-               if (rve)
 +              if (result == BIGINT_INVALID)
 +                      return NULL;
+               s0 = (char *)(void *)result;
+               strcpy(s0, "0");
+               if (rve)
                        *rve = s0 + 1;
-               return s0;
-               }
+               return s0;
+       }
  
        b = d2b(value(d), &be, &bbits);
  #ifdef Sudden_Underflow
Simple merge