static void *php_bz2_alloc(void *opaque, int items, int size)
{
- return (void *)pemalloc(items * size, ((php_bz2_filter_data*)opaque)->persistent);
+ return (void *)safe_pemalloc(items, size, 0, ((php_bz2_filter_data*)opaque)->persistent);
}
static void php_bz2_free(void *opaque, void *address)
/* Create this filter */
data = pecalloc(1, sizeof(php_bz2_filter_data), persistent);
+ if (!data) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %d 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 TSRMLS_CC, E_WARNING, "Failed allocating %d 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 TSRMLS_CC, E_WARNING, "Failed allocating %d bytes.", data->outbuf_len);
+ pefree(data->inbuf, persistent);
+ pefree(data, persistent);
+ return NULL;
+ }
if (strcasecmp(filtername, "bzip2.decompress") == 0) {
int smallFootprint = 0;
static voidpf php_zlib_alloc(voidpf opaque, uInt items, uInt size)
{
- return (voidpf)pemalloc(items * size, ((php_zlib_filter_data*)opaque)->persistent);
+ return (voidpf)safe_pemalloc(items, size, 0, ((php_zlib_filter_data*)opaque)->persistent);
}
static void php_zlib_free(voidpf opaque, voidpf address)
/* Create this filter */
data = pecalloc(1, sizeof(php_zlib_filter_data), persistent);
+ if (!data) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %d bytes.", data->inbuf_len);
+ return NULL;
+ }
/* Circular reference */
data->strm.opaque = (voidpf) data;
data->strm.zfree = (free_func) php_zlib_free;
data->strm.avail_out = data->outbuf_len = data->inbuf_len = 2048;
data->strm.next_in = data->inbuf = (Bytef *) pemalloc(data->inbuf_len, persistent);
+ if (!data->inbuf) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %d bytes.", data->inbuf_len);
+ pefree(data, persistent);
+ return NULL;
+ }
data->strm.avail_in = 0;
data->strm.next_out = data->outbuf = (Bytef *) pemalloc(data->outbuf_len, persistent);
+ if (!data->outbuf) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed allocating %d bytes.", data->inbuf_len);
+ pefree(data->inbuf, persistent);
+ pefree(data, persistent);
+ return NULL;
+ }
+
data->strm.data_type = Z_ASCII;
if (strcasecmp(filtername, "zlib.inflate") == 0) {