diff options
author | Thomas Punt <tpunt@hotmail.co.uk> | 2017-03-16 08:27:57 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-03-16 12:23:55 +0100 |
commit | 932c4b35dc0fece175ca2764e4c82493a5004273 (patch) | |
tree | 11fe3a3551a00a9746f507e4af2c71c6d1dba0d1 /sapi/cli/php_cli_server.c | |
parent | 9d9defa29aafd3b8cfaed8c6e3f8e59c98d0fcb7 (diff) | |
download | php-git-932c4b35dc0fece175ca2764e4c82493a5004273.tar.gz |
Remove more unnecessary checks on Zend's allocator functions
Diffstat (limited to 'sapi/cli/php_cli_server.c')
-rw-r--r-- | sapi/cli/php_cli_server.c | 37 |
1 files changed, 2 insertions, 35 deletions
diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 62e1601c09..de4cfb2195 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -928,9 +928,6 @@ static size_t php_cli_server_buffer_size(const php_cli_server_buffer *buffer) /* static php_cli_server_chunk *php_cli_server_chunk_immortal_new(const char *buf, size_t len) /* {{{ */ { php_cli_server_chunk *chunk = pemalloc(sizeof(php_cli_server_chunk), 1); - if (!chunk) { - return NULL; - } chunk->type = PHP_CLI_SERVER_CHUNK_IMMORTAL; chunk->next = NULL; @@ -942,9 +939,6 @@ static php_cli_server_chunk *php_cli_server_chunk_immortal_new(const char *buf, static php_cli_server_chunk *php_cli_server_chunk_heap_new(void *block, char *buf, size_t len) /* {{{ */ { php_cli_server_chunk *chunk = pemalloc(sizeof(php_cli_server_chunk), 1); - if (!chunk) { - return NULL; - } chunk->type = PHP_CLI_SERVER_CHUNK_HEAP; chunk->next = NULL; @@ -957,9 +951,6 @@ static php_cli_server_chunk *php_cli_server_chunk_heap_new(void *block, char *bu static php_cli_server_chunk *php_cli_server_chunk_heap_new_self_contained(size_t len) /* {{{ */ { php_cli_server_chunk *chunk = pemalloc(sizeof(php_cli_server_chunk) + len, 1); - if (!chunk) { - return NULL; - } chunk->type = PHP_CLI_SERVER_CHUNK_HEAP; chunk->next = NULL; @@ -1215,12 +1206,6 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s #if HAVE_GETADDRINFO && HAVE_IPV6 case AF_INET6: sa = pemalloc(sizeof(struct sockaddr_in6), 1); - if (!sa) { - closesocket(retval); - retval = SOCK_ERR; - *errstr = NULL; - goto out; - } *(struct sockaddr_in6 *)sa = *(struct sockaddr_in6 *)*p; ((struct sockaddr_in6 *)sa)->sin6_port = htons(*port); *socklen = sizeof(struct sockaddr_in6); @@ -1228,12 +1213,6 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s #endif case AF_INET: sa = pemalloc(sizeof(struct sockaddr_in), 1); - if (!sa) { - closesocket(retval); - retval = SOCK_ERR; - *errstr = NULL; - goto out; - } *(struct sockaddr_in *)sa = *(struct sockaddr_in *)*p; ((struct sockaddr_in *)sa)->sin_port = htons(*port); *socklen = sizeof(struct sockaddr_in); @@ -1370,10 +1349,6 @@ static void php_cli_server_request_translate_vpath(php_cli_server_request *reque size_t prev_path_len = 0; int is_static_file = 0; - if (!buf) { - return; - } - memmove(p, document_root, document_root_len); p += document_root_len; vpath = p; @@ -1642,9 +1617,6 @@ static int php_cli_server_client_read_request_on_body(php_http_parser *parser, c php_cli_server_client *client = parser->data; if (!client->request.content) { client->request.content = pemalloc(parser->content_length, 1); - if (!client->request.content) { - return -1; - } client->request.content_len = 0; } client->request.content = perealloc(client->request.content, client->request.content_len + length, 1); @@ -1720,9 +1692,6 @@ static int php_cli_server_client_read_request(php_cli_server_client *client, cha } if (client->current_header_name) { char *header_name = safe_pemalloc(client->current_header_name_len, 1, 1, 1); - if (!header_name) { - return -1; - } memmove(header_name, client->current_header_name, client->current_header_name_len); client->current_header_name = header_name; client->current_header_name_allocated = 1; @@ -2389,9 +2358,6 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke php_socket_t client_sock; socklen_t socklen = server->socklen; struct sockaddr *sa = pemalloc(server->socklen, 1); - if (!sa) { - return FAILURE; - } client_sock = accept(server->server_sock, sa, &socklen); if (!ZEND_VALID_SOCKET(client_sock)) { char *errstr; @@ -2406,7 +2372,8 @@ static int php_cli_server_do_event_for_each_fd_callback(void *_params, php_socke closesocket(client_sock); return SUCCESS; } - if (!(client = pemalloc(sizeof(php_cli_server_client), 1)) || FAILURE == php_cli_server_client_ctor(client, server, client_sock, sa, socklen)) { + client = pemalloc(sizeof(php_cli_server_client), 1); + if (FAILURE == php_cli_server_client_ctor(client, server, client_sock, sa, socklen)) { php_cli_server_logf("Failed to create a new request object"); pefree(sa, 1); closesocket(client_sock); |