if you are using safe_emalloc() you can remove all those ' == NULL' tests.
Nuno

On 7/10/07, Antony Dovgal <[EMAIL PROTECTED]> wrote:
tony2001                Tue Jul 10 11:07:56 2007 UTC

 Modified files:
   /php-src/ext/bcmath/libbcmath/src   div.c init.c num2str.c
 Log:
 use safe_emalloc()


http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/div.c?r1=1.3&r2=1.4&diff_format=u
Index: php-src/ext/bcmath/libbcmath/src/div.c
diff -u php-src/ext/bcmath/libbcmath/src/div.c:1.3 
php-src/ext/bcmath/libbcmath/src/div.c:1.4
--- php-src/ext/bcmath/libbcmath/src/div.c:1.3  Fri Nov 22 09:25:29 2002
+++ php-src/ext/bcmath/libbcmath/src/div.c      Tue Jul 10 11:07:56 2007
@@ -127,13 +127,13 @@
    extra = scale - scale1;
  else
    extra = 0;
-  num1 = (unsigned char *) emalloc (n1->n_len+n1->n_scale+extra+2);
+  num1 = (unsigned char *) safe_emalloc (1, n1->n_len+n1->n_scale, extra+2);
  if (num1 == NULL) bc_out_of_memory();
  memset (num1, 0, n1->n_len+n1->n_scale+extra+2);
  memcpy (num1+1, n1->n_value, n1->n_len+n1->n_scale);

  len2 = n2->n_len + scale2;
-  num2 = (unsigned char *) emalloc (len2+1);
+  num2 = (unsigned char *) safe_emalloc (1, len2, 1);
  if (num2 == NULL) bc_out_of_memory();
  memcpy (num2, n2->n_value, len2);
  *(num2+len2) = 0;
@@ -164,7 +164,7 @@
  memset (qval->n_value, 0, qdigits);

  /* Allocate storage for the temporary storage mval. */
-  mval = (unsigned char *) emalloc (len2+1);
+  mval = (unsigned char *) safe_emalloc (1, len2, 1);
  if (mval == NULL) bc_out_of_memory ();

  /* Now for the full divide algorithm. */
http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/init.c?r1=1.6&r2=1.7&diff_format=u
Index: php-src/ext/bcmath/libbcmath/src/init.c
diff -u php-src/ext/bcmath/libbcmath/src/init.c:1.6 
php-src/ext/bcmath/libbcmath/src/init.c:1.7
--- php-src/ext/bcmath/libbcmath/src/init.c:1.6 Tue Dec  9 23:59:33 2003
+++ php-src/ext/bcmath/libbcmath/src/init.c     Tue Jul 10 11:07:56 2007
@@ -51,7 +51,7 @@
  bc_num temp;

  /* PHP Change:  malloc() -> pemalloc(), removed free_list code */
-  temp = (bc_num) pemalloc (sizeof(bc_struct)+length+scale, persistent);
+  temp = (bc_num) safe_pemalloc (1, sizeof(bc_struct)+length, scale, 
persistent);
 #if 0
  if (_bc_Free_list != NULL) {
    temp = _bc_Free_list;
@@ -66,7 +66,7 @@
  temp->n_scale = scale;
  temp->n_refs = 1;
  /* PHP Change:  malloc() -> pemalloc() */
-  temp->n_ptr = (char *) pemalloc (length+scale, persistent);
+  temp->n_ptr = (char *) safe_pemalloc (1, length, scale, persistent);
  if (temp->n_ptr == NULL) bc_out_of_memory();
  temp->n_value = temp->n_ptr;
  memset (temp->n_ptr, 0, length+scale);
http://cvs.php.net/viewvc.cgi/php-src/ext/bcmath/libbcmath/src/num2str.c?r1=1.2&r2=1.3&diff_format=u
Index: php-src/ext/bcmath/libbcmath/src/num2str.c
diff -u php-src/ext/bcmath/libbcmath/src/num2str.c:1.2 
php-src/ext/bcmath/libbcmath/src/num2str.c:1.3
--- php-src/ext/bcmath/libbcmath/src/num2str.c:1.2      Sun Nov 26 09:34:01 2000
+++ php-src/ext/bcmath/libbcmath/src/num2str.c  Tue Jul 10 11:07:56 2007
@@ -51,9 +51,9 @@
  /* Allocate the string memory. */
  signch = ( num->n_sign == PLUS ? 0 : 1 );  /* Number of sign chars. */
  if (num->n_scale > 0)
-    str = (char *) emalloc (num->n_len + num->n_scale + 2 + signch);
+    str = (char *) safe_emalloc (1, num->n_len + num->n_scale, 2 + signch);
  else
-    str = (char *) emalloc (num->n_len + 1 + signch);
+    str = (char *) safe_emalloc (1, num->n_len, 1 + signch);
  if (str == NULL) bc_out_of_memory();

  /* The negative sign if needed. */

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to