From: Ilia Alshanetsky Date: Sat, 18 Jan 2003 20:01:46 +0000 (+0000) Subject: Removed pointless memory allocation checks. X-Git-Tag: PHP_5_0_dev_before_13561_fix~138 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71e9f8cdd5e66d64335fb5f657ac3f801e517b90;p=php Removed pointless memory allocation checks. --- diff --git a/ext/standard/exec.c b/ext/standard/exec.c index d617e85226..13ed72a6ac 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -67,10 +67,6 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC) #endif buf = (char *) emalloc(EXEC_INPUT_BUF); - if (!buf) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to emalloc %d bytes for exec buffer", EXEC_INPUT_BUF); - return -1; - } buflen = EXEC_INPUT_BUF; if (PG(safe_mode)) { @@ -162,14 +158,6 @@ int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC) do { if ( buflen <= (l+1) ) { buf = erealloc(buf, buflen + EXEC_INPUT_BUF); - if ( buf == NULL ) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to erealloc %d bytes for exec buffer", - buflen + EXEC_INPUT_BUF); -#if PHP_SIGCHILD - signal (SIGCHLD, sig_handler); -#endif - return -1; - } buflen += EXEC_INPUT_BUF; } diff --git a/ext/standard/file.c b/ext/standard/file.c index dcdd3a9b3e..baacdc9129 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -1495,7 +1495,7 @@ PHP_FUNCTION(fscanf) WRONG_PARAM_COUNT; } args = (zval ***)emalloc(argCount * sizeof(zval **)); - if (!args || (zend_get_parameters_array_ex(argCount, args) == FAILURE)) { + if (zend_get_parameters_array_ex(argCount, args) == FAILURE) { efree( args ); WRONG_PARAM_COUNT; } diff --git a/ext/standard/image.c b/ext/standard/image.c index 2b06e0ed39..c16ee1c6f9 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -215,10 +215,6 @@ static struct gfxinfo *php_handle_swc(php_stream * stream TSRMLS_DC) do { szlength=slength*(1<bits = php_stream_getc(stream); result->height = php_read2(stream TSRMLS_CC); @@ -605,9 +598,6 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream TSRMLS_DC) } result = (struct gfxinfo *)ecalloc(1, sizeof(struct gfxinfo)); - if (!result) { - return NULL; - } dummy_short = php_read2(stream TSRMLS_CC); /* Lsiz */ dummy_short = php_read2(stream TSRMLS_CC); /* Rsiz */ diff --git a/ext/standard/info.c b/ext/standard/info.c index 12cad0e948..3a521ef3d0 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -439,10 +439,7 @@ PHPAPI void php_print_info(int flag TSRMLS_DC) for (zend_hash_internal_pointer_reset(url_stream_wrappers_hash); zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, NULL, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(url_stream_wrappers_hash)) { - if (NULL == (stream_protocols_buf = erealloc(stream_protocols_buf, - stream_protocols_buf_len + stream_protocol_len + 2 /* ", " */ + 1 /* 0 byte at end */))) { - break; - } + stream_protocols_buf = erealloc(stream_protocols_buf, stream_protocols_buf_len + stream_protocol_len + 2 + 1); memcpy(stream_protocols_buf + stream_protocols_buf_len, stream_protocol, stream_protocol_len); stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len] = ','; stream_protocols_buf[stream_protocols_buf_len + stream_protocol_len + 1] = ' '; diff --git a/ext/standard/metaphone.c b/ext/standard/metaphone.c index e6cc2cf67f..10e3396edf 100644 --- a/ext/standard/metaphone.c +++ b/ext/standard/metaphone.c @@ -145,9 +145,7 @@ static char Lookahead(char *word, int how_far) * could be one though; or more too). */ #define Phonize(c) { \ if (p_idx >= max_buffer_len) { \ - if (NULL == (*phoned_word = erealloc(*phoned_word, max_buffer_len + 2))) { \ - return -1; \ - } \ + *phoned_word = erealloc(*phoned_word, max_buffer_len + 2); \ max_buffer_len += 2; \ } \ (*phoned_word)[p_idx++] = c; \ @@ -185,13 +183,9 @@ static int metaphone(char *word, int word_len, int max_phonemes, char **phoned_w if (max_phonemes == 0) { /* Assume largest possible */ max_buffer_len = word_len; *phoned_word = 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); - if (!*phoned_word) - return -1; } diff --git a/ext/standard/string.c b/ext/standard/string.c index 65b995de86..b6fe0f03ae 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -113,9 +113,6 @@ static char *php_bin2hex(const unsigned char *old, const size_t oldlen, size_t * size_t i, j; result = (char *) emalloc(oldlen * 2 * sizeof(char) + 1); - if (!result) { - return result; - } for (i = j = 0; i < oldlen; i++) { result[j++] = hexconvtab[old[i] >> 4];