]> granicus.if.org Git - php/commitdiff
emalloc -> safe_emalloc.
authorIlia Alshanetsky <iliaa@php.net>
Tue, 22 Apr 2003 01:38:36 +0000 (01:38 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Tue, 22 Apr 2003 01:38:36 +0000 (01:38 +0000)
ext/ereg/ereg.c
ext/standard/metaphone.c
ext/standard/pack.c
ext/standard/reg.c

index 2af1fefb3a592afec5ec3cb677fa81b33ae8061e..193e43a24754f90993e07bab3b1925b309456df9 100644 (file)
@@ -118,7 +118,7 @@ static void php_reg_eprint(int err, regex_t *re) {
        /* get the length of the message */
        buf_len = regerror(REG_ITOA | err, re, NULL, 0);
        if (buf_len) {
-               buf = (char *)emalloc(buf_len * sizeof(char));
+               buf = (char *)safe_emalloc(buf_len, sizeof(char), 0);
                if (!buf) return; /* fail silently */
                /* finally, get the error message */
                regerror(REG_ITOA | err, re, buf, buf_len);
@@ -130,7 +130,7 @@ static void php_reg_eprint(int err, regex_t *re) {
        if (len) {
                TSRMLS_FETCH();
 
-               message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
+               message = (char *)safe_emalloc((buf_len + len + 2), sizeof(char), 0);
                if (!message) {
                        return; /* fail silently */
                }
@@ -298,7 +298,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
        /* start with a buffer that is twice the size of the stringo
           we're doing replacements in */
        buf_len = 2 * string_len + 1;
-       buf = emalloc(buf_len * sizeof(char));
+       buf = safe_emalloc(buf_len, sizeof(char), 0);
 
        err = pos = 0;
        buf[0] = '\0';
@@ -373,7 +373,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
                                new_l = strlen (buf) + 1;
                                if (new_l + 1 > buf_len) {
                                        buf_len = 1 + buf_len + 2 * new_l;
-                                       nbuf = emalloc(buf_len * sizeof(char));
+                                       nbuf = safe_emalloc(buf_len, sizeof(char), 0);
                                        strcpy(nbuf, buf);
                                        efree(buf);
                                        buf = nbuf;
@@ -388,7 +388,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
                        new_l = strlen(buf) + strlen(&string[pos]);
                        if (new_l + 1 > buf_len) {
                                buf_len = new_l + 1; /* now we know exactly how long it is */
-                               nbuf = emalloc(buf_len * sizeof(char));
+                               nbuf = safe_emalloc(buf_len, sizeof(char), 0);
                                strcpy(nbuf, buf);
                                efree(buf);
                                buf = nbuf;
@@ -607,7 +607,7 @@ PHPAPI PHP_FUNCTION(sql_regcase)
        }       
        convert_to_string_ex(string);
        
-       tmp = emalloc((Z_STRLEN_PP(string) * 4) + 1);
+       tmp = safe_emalloc(Z_STRLEN_PP(string), 4, 1);
        
        for (i = j = 0; i < Z_STRLEN_PP(string); i++) {
                c = (unsigned char) Z_STRVAL_PP(string)[i];
index def77a77140450526c4fa83efb0906a052926329..b433208d9cfa4381fb16669dd5f44eab03b50e15 100644 (file)
@@ -183,12 +183,12 @@ static int metaphone(char *word, int word_len, int max_phonemes, char **phoned_w
 /*-- Allocate memory for our phoned_phrase --*/
        if (max_phonemes == 0) {        /* Assume largest possible */
                max_buffer_len = word_len;
-               *phoned_word = emalloc(sizeof(char) * word_len + 1);
+               *phoned_word = safe_emalloc(sizeof(char), word_len, 1);
                if (!*phoned_word)
                        return -1;
        } else {
                max_buffer_len = max_phonemes;
-               *phoned_word = emalloc(sizeof(char) * max_phonemes + 1);
+               *phoned_word = safe_emalloc(sizeof(char), max_phonemes, 1);
                if (!*phoned_word)
                        return -1;
        }
index 0002aaeb377a67b8da1ac711b74394b82526a1bb..cce7913a9ab8093167646fc81607f6741bef1cd6 100644 (file)
@@ -122,7 +122,7 @@ PHP_FUNCTION(pack)
                WRONG_PARAM_COUNT;
        }
 
-       argv = emalloc(argc * sizeof(zval **));
+       argv = safe_emalloc(sizeof(zval **), argc, 0);
 
        if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
                efree(argv);
@@ -134,8 +134,8 @@ PHP_FUNCTION(pack)
        formatlen = Z_STRLEN_PP(argv[0]);
 
        /* We have a maximum of <formatlen> format codes to deal with */
-       formatcodes = emalloc(formatlen * sizeof(*formatcodes));
-       formatargs = emalloc(formatlen * sizeof(*formatargs));
+       formatcodes = safe_emalloc(formatlen, sizeof(*formatcodes), 0);
+       formatargs = safe_emalloc(formatlen, sizeof(*formatargs), 0);
        currentarg = 1;
 
        /* Preprocess format into formatcodes and formatargs */
index 2af1fefb3a592afec5ec3cb677fa81b33ae8061e..193e43a24754f90993e07bab3b1925b309456df9 100644 (file)
@@ -118,7 +118,7 @@ static void php_reg_eprint(int err, regex_t *re) {
        /* get the length of the message */
        buf_len = regerror(REG_ITOA | err, re, NULL, 0);
        if (buf_len) {
-               buf = (char *)emalloc(buf_len * sizeof(char));
+               buf = (char *)safe_emalloc(buf_len, sizeof(char), 0);
                if (!buf) return; /* fail silently */
                /* finally, get the error message */
                regerror(REG_ITOA | err, re, buf, buf_len);
@@ -130,7 +130,7 @@ static void php_reg_eprint(int err, regex_t *re) {
        if (len) {
                TSRMLS_FETCH();
 
-               message = (char *)emalloc((buf_len + len + 2) * sizeof(char));
+               message = (char *)safe_emalloc((buf_len + len + 2), sizeof(char), 0);
                if (!message) {
                        return; /* fail silently */
                }
@@ -298,7 +298,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
        /* start with a buffer that is twice the size of the stringo
           we're doing replacements in */
        buf_len = 2 * string_len + 1;
-       buf = emalloc(buf_len * sizeof(char));
+       buf = safe_emalloc(buf_len, sizeof(char), 0);
 
        err = pos = 0;
        buf[0] = '\0';
@@ -373,7 +373,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
                                new_l = strlen (buf) + 1;
                                if (new_l + 1 > buf_len) {
                                        buf_len = 1 + buf_len + 2 * new_l;
-                                       nbuf = emalloc(buf_len * sizeof(char));
+                                       nbuf = safe_emalloc(buf_len, sizeof(char), 0);
                                        strcpy(nbuf, buf);
                                        efree(buf);
                                        buf = nbuf;
@@ -388,7 +388,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
                        new_l = strlen(buf) + strlen(&string[pos]);
                        if (new_l + 1 > buf_len) {
                                buf_len = new_l + 1; /* now we know exactly how long it is */
-                               nbuf = emalloc(buf_len * sizeof(char));
+                               nbuf = safe_emalloc(buf_len, sizeof(char), 0);
                                strcpy(nbuf, buf);
                                efree(buf);
                                buf = nbuf;
@@ -607,7 +607,7 @@ PHPAPI PHP_FUNCTION(sql_regcase)
        }       
        convert_to_string_ex(string);
        
-       tmp = emalloc((Z_STRLEN_PP(string) * 4) + 1);
+       tmp = safe_emalloc(Z_STRLEN_PP(string), 4, 1);
        
        for (i = j = 0; i < Z_STRLEN_PP(string); i++) {
                c = (unsigned char) Z_STRVAL_PP(string)[i];