]> granicus.if.org Git - php/commitdiff
emalloc -> safe_emalloc
authorIlia Alshanetsky <iliaa@php.net>
Wed, 30 Apr 2003 21:53:53 +0000 (21:53 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 30 Apr 2003 21:53:53 +0000 (21:53 +0000)
ext/ldap/ldap.c
ext/pdf/pdf.c

index f070cdba594b8675a8f52fe91c9dcab3ed3ae417..8529013cbf3467749dae5e765b50be3848d98f2b 100644 (file)
@@ -564,7 +564,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
                        }
 
                        num_attribs = zend_hash_num_elements(Z_ARRVAL_PP(attrs));
-                       if ((ldap_attrs = emalloc((num_attribs+1) * sizeof(char *))) == NULL) {
+                       if ((ldap_attrs = safe_emalloc((num_attribs+1), sizeof(char *), 0)) == NULL) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not allocate memory");
                                RETURN_FALSE;
                        }
@@ -644,8 +644,8 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
                        ldap_filter = Z_STRVAL_PP(filter);
                }
 
-               lds = emalloc(nlinks * sizeof(ldap_linkdata));
-               rcs = emalloc(nlinks * sizeof(*rcs));
+               lds = safe_emalloc(nlinks, sizeof(ldap_linkdata), 0);
+               rcs = safe_emalloc(nlinks, sizeof(*rcs), 0);
                
                zend_hash_internal_pointer_reset(Z_ARRVAL_PP(link));
                for (i=0; i<nlinks; i++) {
@@ -1274,8 +1274,8 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
        ldap_dn = Z_STRVAL_PP(dn);
 
        num_attribs = zend_hash_num_elements(Z_ARRVAL_PP(entry));
-       ldap_mods = emalloc((num_attribs+1) * sizeof(LDAPMod *));
-       num_berval = emalloc(num_attribs * sizeof(int));
+       ldap_mods = safe_emalloc((num_attribs+1), sizeof(LDAPMod *), 0);
+       num_berval = safe_emalloc(num_attribs, sizeof(int), 0);
        zend_hash_internal_pointer_reset(Z_ARRVAL_PP(entry));
 
        /* added by gerrit thomson to fix ldap_add using ldap_mod_add */
@@ -1311,7 +1311,7 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper)
                }
                
                num_berval[i] = num_values;
-               ldap_mods[i]->mod_bvalues = emalloc((num_values + 1) * sizeof(struct berval *));
+               ldap_mods[i]->mod_bvalues = safe_emalloc((num_values + 1), sizeof(struct berval *), 0);
 
 /* allow for arrays with one element, no allowance for arrays with none but probably not required, gerrit thomson. */
                if ((num_values == 1) && (Z_TYPE_PP(value) != IS_ARRAY)) {
@@ -1703,7 +1703,7 @@ PHP_FUNCTION(ldap_set_option)
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected non-empty array value for this option");
                                 RETURN_FALSE;
                         }
-                       ctrls = emalloc((1 + ncontrols) * sizeof(*ctrls));
+                       ctrls = safe_emalloc((1 + ncontrols), sizeof(*ctrls), 0);
                        *ctrls = NULL;
                        ctrlp = ctrls;
                        zend_hash_internal_pointer_reset(Z_ARRVAL_PP(newval));
index a9c6794af7a9a4aafcbd9549e59f106a43c22606..75e53f93fc9e3c99286965a25d5afdbf3b361b28 100644 (file)
@@ -2457,7 +2457,7 @@ PHP_FUNCTION(pdf_setpolydash)
        array = Z_ARRVAL_PP(arg2);
        len = zend_hash_num_elements(array);
 
-       darray = emalloc(len * sizeof(double));
+       darray = safe_emalloc(len, sizeof(double), 0);
        zend_hash_internal_pointer_reset(array);
        for (i=0; i<len; i++) {
            zval *keydata, **keydataptr;