]> granicus.if.org Git - php/commitdiff
Remove superfluous allocation checks around ZMM-based functions
authorThomas Punt <tpunt@hotmail.co.uk>
Sat, 1 Apr 2017 18:38:37 +0000 (19:38 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Sat, 1 Apr 2017 22:58:19 +0000 (00:58 +0200)
ext/mbstring/mbstring.c
ext/mysqlnd/mysqlnd_net.c
ext/mysqlnd/mysqlnd_vio.c
ext/opcache/Optimizer/zend_cfg.c
ext/opcache/Optimizer/zend_ssa.c
ext/opcache/Optimizer/zend_worklist.h
ext/standard/filters.c
main/streams/filter.c
sapi/litespeed/lsapi_main.c

index 05ebadb9094e4dff80a173e6927653b13573c960..3edaf87f661259fe8f54cf7d5867baffe1df1cb8 100644 (file)
@@ -732,9 +732,6 @@ php_mb_parse_encoding_list(const char *value, size_t value_length, const mbfl_en
                }
                else
                        tmpstr = (char *)estrndup(value, value_length);
-               if (tmpstr == NULL) {
-                       return FAILURE;
-               }
                /* count the number of listed encoding names */
                endp = tmpstr + value_length;
                n = 1;
index c6a7f721d9a21a7730ead191d1a1b7d357fd9f03..80b6b46b74b53beaf2be1281ed3d08a2a040c0f2 100644 (file)
@@ -906,9 +906,6 @@ MYSQLND_METHOD(mysqlnd_net, enable_ssl)(MYSQLND_NET * const net)
        zend_bool any_flag = FALSE;
 
        DBG_ENTER("mysqlnd_net::enable_ssl");
-       if (!context) {
-               DBG_RETURN(FAIL);
-       }
 
        if (net->data->options.ssl_key) {
                zval key_zval;
index 33de52c6be20651161ad0c51912c87431f1ebfa2..ef097c94611ed1094f12cedb24355d961cb36bd3 100644 (file)
@@ -492,9 +492,6 @@ MYSQLND_METHOD(mysqlnd_vio, enable_ssl)(MYSQLND_VIO * const net)
        zend_bool any_flag = FALSE;
 
        DBG_ENTER("mysqlnd_vio::enable_ssl");
-       if (!context) {
-               DBG_RETURN(FAIL);
-       }
 
        if (net->data->options.ssl_key) {
                zval key_zval;
index 2163d7c3a2633d9f9ead3825937ed16e0028ece5..06cf266b9d809c7280d4483e2a503abde733d62c 100644 (file)
@@ -291,9 +291,6 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
        cfg->split_at_recv = (build_flags & ZEND_CFG_RECV_ENTRY) != 0 && (op_array->fn_flags & ZEND_ACC_HAS_TYPE_HINTS) == 0;
 
        cfg->map = block_map = zend_arena_calloc(arena, op_array->last, sizeof(uint32_t));
-       if (!block_map) {
-               return FAILURE;
-       }
 
        /* Build CFG, Step 1: Find basic blocks starts, calculate number of blocks */
        BB_START(0);
@@ -460,9 +457,6 @@ int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, uint32_t b
 
        /* Build CFG, Step 2: Build Array of Basic Blocks */
        cfg->blocks = blocks = zend_arena_calloc(arena, sizeof(zend_basic_block), blocks_count);
-       if (!blocks) {
-               return FAILURE;
-       }
 
        blocks_count = -1;
 
@@ -594,10 +588,6 @@ int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg) /* {{{ */
 
        cfg->predecessors = predecessors = (int*)zend_arena_calloc(arena, sizeof(int), edges);
 
-       if (!predecessors) {
-               return FAILURE;
-       }
-
        edges = 0;
        for (b = blocks; b < end; b++) {
                if (b->flags & ZEND_BB_REACHABLE) {
index 2f5f3597675f388867a496aa710f13db481f2c8e..4c3361b5c641298dd03cb14df1fd78e3930f60d1 100644 (file)
@@ -869,9 +869,6 @@ int zend_build_ssa(zend_arena **arena, const zend_script *script, const zend_op_
 
        ssa->rt_constants = (build_flags & ZEND_RT_CONSTANTS);
        ssa_blocks = zend_arena_calloc(arena, blocks_count, sizeof(zend_ssa_block));
-       if (!ssa_blocks) {
-               return FAILURE;
-       }
        ssa->blocks = ssa_blocks;
 
        /* Compute Variable Liveness */
index 73c0bca854b43995e4b4d545a61a7053a270668f..98b20a9ea585193c305b17f2585e0c285cf6dc30 100644 (file)
@@ -44,9 +44,6 @@ static inline int zend_worklist_stack_prepare(zend_arena **arena, zend_worklist_
        ZEND_ASSERT(len >= 0);
 
        stack->buf = (int*)zend_arena_calloc(arena, sizeof(*stack->buf), len);
-       if (!stack->buf) {
-               return FAILURE;
-       }
        stack->len = 0;
        stack->capacity = len;
 
@@ -91,9 +88,6 @@ static inline int zend_worklist_prepare(zend_arena **arena, zend_worklist *workl
 {
        ZEND_ASSERT(len >= 0);
        worklist->visited = (zend_bitset)zend_arena_calloc(arena, sizeof(zend_ulong), zend_bitset_len(len));
-       if (!worklist->visited) {
-               return FAILURE;
-       }
        return zend_worklist_stack_prepare(arena, &worklist->stack, len);
 }
 
index 37205d59accd9d1f8a1e2786ea8ad5dbab61301b..ff955ae3303a5cb991de972c6e8dbe2c35180aee 100644 (file)
@@ -1807,10 +1807,6 @@ static php_stream_filter *consumed_filter_create(const char *filtername, zval *f
 
        /* Create this filter */
        data = pecalloc(1, sizeof(php_consumed_filter_data), persistent);
-       if (!data) {
-               php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", sizeof(php_consumed_filter_data));
-               return NULL;
-       }
        data->persistent = persistent;
        data->consumed = 0;
        data->offset = ~0;
@@ -2015,10 +2011,6 @@ static php_stream_filter *chunked_filter_create(const char *filtername, zval *fi
 
        /* Create this filter */
        data = (php_chunked_filter_data *)pecalloc(1, sizeof(php_chunked_filter_data), persistent);
-       if (!data) {
-               php_error_docref(NULL, E_WARNING, "Failed allocating %zd bytes", sizeof(php_chunked_filter_data));
-               return NULL;
-       }
        data->state = CHUNK_SIZE_START;
        data->chunk_size = 0;
        data->persistent = persistent;
index 901cf00ad946add7a61ede289157d8f8ec8646cd..bb167c4409663ddbb86647719be2f8d9fa2f929b 100644 (file)
@@ -130,10 +130,6 @@ PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **le
        *left = (php_stream_bucket*)pecalloc(1, sizeof(php_stream_bucket), in->is_persistent);
        *right = (php_stream_bucket*)pecalloc(1, sizeof(php_stream_bucket), in->is_persistent);
 
-       if (*left == NULL || *right == NULL) {
-               goto exit_fail;
-       }
-
        (*left)->buf = pemalloc(length, in->is_persistent);
        (*left)->buflen = length;
        memcpy((*left)->buf, in->buf, length);
@@ -149,21 +145,6 @@ PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **le
        (*right)->is_persistent = in->is_persistent;
 
        return SUCCESS;
-
-exit_fail:
-       if (*right) {
-               if ((*right)->buf) {
-                       pefree((*right)->buf, in->is_persistent);
-               }
-               pefree(*right, in->is_persistent);
-       }
-       if (*left) {
-               if ((*left)->buf) {
-                       pefree((*left)->buf, in->is_persistent);
-               }
-               pefree(*left, in->is_persistent);
-       }
-       return FAILURE;
 }
 
 PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket)
index cf9e4233679579a0b388b18b41544c8fb79dac32..7b17035ae71368bc40d3336920aca6fb057ab6ff 100644 (file)
@@ -731,8 +731,6 @@ static int lsapi_activate_user_ini_mk_path(_lsapi_activate_user_ini_ctx *ctx,
     /* Extract dir name from path_translated * and store it in 'path' */
     ctx->path_len = strlen(ctx->path);
     path = ctx->path = estrndup(SG(request_info).path_translated, ctx->path_len);
-    if (!path)
-        return FAILURE;
     ctx->path_len = zend_dirname(path, ctx->path_len);
     DEBUG_MESSAGE("dirname: %s", ctx->path);