/* Create this filter */
data = pecalloc(1, sizeof(php_bz2_filter_data), persistent);
- if (!data) {
- php_error_docref(NULL, E_WARNING, "Failed allocating %zu bytes", sizeof(php_bz2_filter_data));
- return NULL;
- }
/* Circular reference */
data->strm.opaque = (void *) data;
data->persistent = persistent;
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
data->strm.next_in = data->inbuf = (char *) pemalloc(data->inbuf_len, persistent);
- if (!data->inbuf) {
- php_error_docref(NULL, E_WARNING, "Failed allocating %zu bytes", data->inbuf_len);
- pefree(data, persistent);
- return NULL;
- }
data->strm.avail_in = 0;
data->strm.next_out = data->outbuf = (char *) pemalloc(data->outbuf_len, persistent);
- if (!data->outbuf) {
- php_error_docref(NULL, E_WARNING, "Failed allocating %zu bytes", data->outbuf_len);
- pefree(data->inbuf, persistent);
- pefree(data, persistent);
- return NULL;
- }
if (strcasecmp(filtername, "bzip2.decompress") == 0) {
data->small_footprint = 0;
{
zend_mb_regex_globals *pglobals = pemalloc(
sizeof(zend_mb_regex_globals), 1);
- if (!pglobals) {
- return NULL;
- }
if (SUCCESS != _php_mb_regex_globals_ctor(pglobals)) {
pefree(pglobals, 1);
return NULL;
}
out = emalloc(strlen(in) + 1);
- if (!out) {
- return NULL;
- }
for (i = 0; i <= len; ++i) {
if (i == len || in[i] == ',') {
return 0;
}
- if (!(dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent))) {
- php_error_docref(NULL, E_ERROR, "out of memory while allocating PDO methods.");
- }
+ dbh->cls_methods[kind] = pemalloc(sizeof(HashTable), dbh->is_persistent);
zend_hash_init_ex(dbh->cls_methods[kind], 8, NULL,
dbh->is_persistent? cls_method_pdtor : cls_method_dtor, dbh->is_persistent, 0);
/* create and sort array with pointers to the target_hash buckets */
arTmp = (struct bucketindex *) pemalloc((Z_ARRVAL_P(array)->nNumOfElements + 1) * sizeof(struct bucketindex), Z_ARRVAL_P(array)->u.flags & HASH_FLAG_PERSISTENT);
- if (!arTmp) {
- zval_dtor(return_value);
- RETURN_FALSE;
- }
for (i = 0, idx = 0; idx < Z_ARRVAL_P(array)->nNumUsed; idx++) {
p = Z_ARRVAL_P(array)->arData + idx;
if (Z_TYPE(p->val) == IS_UNDEF) continue;
}
hash = Z_ARRVAL(args[i]);
list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->u.flags & HASH_FLAG_PERSISTENT);
- if (!list) {
- PHP_ARRAY_CMP_FUNC_RESTORE();
-
- efree(ptrs);
- efree(lists);
- RETURN_FALSE;
- }
lists[i] = list;
ptrs[i] = list;
for (idx = 0; idx < hash->nNumUsed; idx++) {
}
hash = Z_ARRVAL(args[i]);
list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), hash->u.flags & HASH_FLAG_PERSISTENT);
- if (!list) {
- PHP_ARRAY_CMP_FUNC_RESTORE();
-
- efree(ptrs);
- efree(lists);
- RETURN_FALSE;
- }
lists[i] = list;
ptrs[i] = list;
for (idx = 0; idx < hash->nNumUsed; idx++) {
php_stream_from_zval(stream, zstream);
- if (!(pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream)))) {
- RETURN_FALSE;
- }
+ pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream));
memcpy(pbuffer, buffer, buffer_len);
IS_ABSOLUTE_PATH(PG(doc_root), length)) {
int path_len = (int)strlen(path_info);
filename = emalloc(length + path_len + 2);
- if (filename) {
- memcpy(filename, PG(doc_root), length);
- if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */
- filename[length++] = PHP_DIR_SEPARATOR;
- }
- if (IS_SLASH(path_info[0])) {
- length--;
- }
- strncpy(filename + length, path_info, path_len + 1);
+ memcpy(filename, PG(doc_root), length);
+ if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */
+ filename[length++] = PHP_DIR_SEPARATOR;
+ }
+ if (IS_SLASH(path_info[0])) {
+ length--;
}
+ strncpy(filename + length, path_info, path_len + 1);
} else {
filename = SG(request_info).path_translated;
}
php_stream_bucket *bucket;
bucket = (php_stream_bucket*)pemalloc(sizeof(php_stream_bucket), is_persistent);
-
- if (bucket == NULL) {
- return NULL;
- }
-
bucket->next = bucket->prev = NULL;
if (is_persistent && !buf_persistent) {
/* all data in a persistent bucket must also be persistent */
bucket->buf = pemalloc(buflen, 1);
-
- if (bucket->buf == NULL) {
- pefree(bucket, 1);
- return NULL;
- }
-
memcpy(bucket->buf, buf, buflen);
bucket->buflen = buflen;
bucket->own_buf = 1;
} else {
tmp = erealloc(ms->data, ms->fpos + count);
}
- if (!tmp) {
- count = ms->fsize - ms->fpos + 1;
- } else {
- ms->data = tmp;
- ms->fsize = ms->fpos + count;
- }
+ ms->data = tmp;
+ ms->fsize = ms->fpos + count;
}
if (!ms->data)
count = 0;
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;
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;
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;
#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);
#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);
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;
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);
}
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;
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;
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);