value_datum = DBM_FETCH(dbf, key_datum);
if (value_datum.dptr) {
- ret = (char *)emalloc(sizeof(char) * value_datum.dsize + 1);
+ ret = (char *)safe_emalloc(sizeof(char), value_datum.dsize, 1);
strncpy(ret, value_datum.dptr, value_datum.dsize);
ret[value_datum.dsize] = '\0';
if (!ret_datum.dptr)
return NULL;
- ret = (char *)emalloc((ret_datum.dsize + 1) * sizeof(char));
+ ret = (char *)safe_emalloc((ret_datum.dsize + 1), sizeof(char), 0);
strncpy(ret, ret_datum.dptr, ret_datum.dsize);
ret[ret_datum.dsize] = '\0';
ret_datum = DBM_NEXTKEY(dbf, key_datum);
if (ret_datum.dptr) {
- ret = (char *)emalloc(sizeof(char) * ret_datum.dsize + 1);
+ ret = (char *)safe_emalloc(sizeof(char), ret_datum.dsize, 1);
strncpy(ret, ret_datum.dptr, ret_datum.dsize);
ret[ret_datum.dsize] = '\0';
#if GDBM
char *buf;
if (flatfile_findkey(dbf, key_datum)) {
- buf = emalloc((buf_size+1) * sizeof(char));
+ buf = safe_emalloc((buf_size+1), sizeof(char), 0);
if (fgets(buf, 15, dbf)) {
num = atoi(buf);
if (num > buf_size) {
rewind(dbf);
- buf = emalloc((buf_size + 1)*sizeof(char));
+ buf = safe_emalloc((buf_size + 1), sizeof(char), 0);
while(!feof(dbf)) {
/* read in the length of the key name */
if (!fgets(buf, 15, dbf))
if (num > buf_size) {
buf_size+=num;
if (buf) efree(buf);
- buf = emalloc((buf_size+1)*sizeof(char));
+ buf = safe_emalloc((buf_size+1), sizeof(char), 0);
}
/* read in the value */
num = fread(buf, sizeof(char), num, dbf);
int size = key_datum.dsize;
rewind(dbf);
- buf = emalloc((buf_size+1)*sizeof(char));
+ buf = safe_emalloc((buf_size+1), sizeof(char), 0);
while (!feof(dbf)) {
if (!fgets(buf, 15, dbf)) break;
num = atoi(buf);
if (num > buf_size) {
if (buf) efree(buf);
buf_size+=num;
- buf = emalloc((buf_size+1)*sizeof(char));
+ buf = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf, sizeof(char), num, dbf);
if (num<0) break;
if (num > buf_size) {
if (buf) efree(buf);
buf_size+=num;
- buf = emalloc((buf_size+1)*sizeof(char));
+ buf = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf, sizeof(char), num, dbf);
if (num<0) break;
int buf_size=1024;
rewind(dbf);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
while(!feof(dbf)) {
if (!fgets(buf.dptr, 15, dbf)) break;
num = atoi(buf.dptr);
if (num > buf_size) {
buf_size+=num;
if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf.dptr, sizeof(char), num, dbf);
if (num<0) break;
if (num > buf_size) {
buf_size+=num;
if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf.dptr, sizeof(char), num, dbf);
if (num<0) break;
int buf_size=1024;
fseek(dbf, CurrentFlatFilePos, SEEK_SET);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
while(!feof(dbf)) {
if (!fgets(buf.dptr, 15, dbf)) break;
num = atoi(buf.dptr);
if (num > buf_size) {
buf_size+=num;
if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf.dptr, sizeof(char), num, dbf);
if (num<0) break;
if (num > buf_size) {
buf_size+=num;
if (buf.dptr) efree(buf.dptr);
- buf.dptr = emalloc((buf_size+1)*sizeof(char));
+ buf.dptr = safe_emalloc((buf_size+1), sizeof(char), 0);
}
num = fread(buf.dptr, sizeof(char), num, dbf);
if (num<0) break;
ctxp = xmlXPathNewContext(docp);
ctxp->node = NULL;
- str = (char*) emalloc((name_len+3) * sizeof(char)) ;
+ str = (char*) safe_emalloc((name_len+3), sizeof(char), 0) ;
sprintf(str ,"//%s",name);
xpathobjp = xmlXPathEval(str, ctxp);
ctxp = xmlXPathNewContext(docp);
ctxp->node = nodep;
- str = (char*) emalloc((name_len+13) * sizeof(char)) ;
+ str = (char*) safe_emalloc((name_len+13), sizeof(char), 0) ;
sprintf(str ,"descendant::%s",name);
xpathobjp = xmlXPathEval(str, ctxp);
*length = l*2+3+1;
if (value)
{
- char* r = emalloc(l*2+3+1);
+ char* r = safe_emalloc(l, 2, 4);
r[0] = 'X';
r[1] = '\'';
for (i = 0; i < nBits / 8; i++)
*length = l*2+3+1;
if (value)
{
- char* r = emalloc(l*2+3+1);
+ char* r = safe_emalloc(l, 2, 1);
r[0] = 'B';
r[1] = '\'';
for (i = 0; i < nBits; i++)
rewind(tmpfp);
- ret = emalloc((lines + 1) * sizeof(char**) + size * sizeof(char*));
+ ret = safe_emalloc((lines + 1), sizeof(char**), size * sizeof(char*));
entry = ret;
text = (char*) (ret + lines + 1);
convert_to_array_ex(styles);
/* copy the style values in the stylearr */
- stylearr = emalloc(sizeof(int) * zend_hash_num_elements(HASH_OF(*styles)));
+ stylearr = safe_emalloc(sizeof(int), zend_hash_num_elements(HASH_OF(*styles)), 0);
zend_hash_internal_pointer_reset_ex(HASH_OF(*styles), &pos);
RETURN_FALSE;
}
- points = (gdPointPtr) emalloc(npoints * sizeof(gdPoint));
+ points = (gdPointPtr) safe_emalloc(npoints, sizeof(gdPoint), 0);
for (i = 0; i < npoints; i++) {
if (zend_hash_index_find(Z_ARRVAL_PP(POINTS), (i * 2), (void **) &var) == SUCCESS) {
oc = gdImageGetPixel(im, x, y);
if (oc==nc || x<0 || x>wx2 || y<0 || y>wy2) return;
- stack = (struct seg *)emalloc(sizeof(struct seg) * ((int)(im->sy*im->sx)/4)+1);
+ stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1);
sp = stack;
/* required! */
pts[i] = (int *) ecalloc(im->sx, sizeof(int));
}
- stack = (struct seg *)emalloc(sizeof(struct seg) * ((int)(im->sy*im->sx)/4)+1);
+ stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1);
sp = stack;
oc = gdImageGetPixel(im, x, y);
}
array_init(return_value);
- delim = emalloc(2 * sizeof(char));
+ delim = safe_emalloc(2, sizeof(char), 0);
cur=IMAPG(imap_folder_objects);
while (cur != NIL) {
MAKE_STD_ZVAL(mboxob);
convert_to_string_ex(ref);
convert_to_string_ex(pat);
- delim = emalloc(2 * sizeof(char));
+ delim = safe_emalloc(2, sizeof(char), 0);
/* set flag for new, improved array of objects list */
IMAPG(folderlist_style) = FLIST_OBJECT;
string = Z_STRVAL_PP(str);
end = Z_STRLEN_PP(str);
- charset = (char *) emalloc((end + 1) * 2);
+ charset = (char *) safe_emalloc((end + 1), 2, 0);
text = &charset[end + 1];
while (offset < end) { /* Reached end of the string? */
if ((charset_token = (long)php_memnstr(&string[offset], "=?", 2, string + end))) { /* Is there anything encoded in the string? */
}
/* allocate memory for j fields */
- columnData = (IIAPI_DATAVALUE *) emalloc(j * sizeof(IIAPI_DATAVALUE));
+ columnData = (IIAPI_DATAVALUE *) safe_emalloc(j, sizeof(IIAPI_DATAVALUE), 0);
for (k = 1; k <= j; k++) {
columnData[k - 1].dv_value = (II_PTR) emalloc((ii_link->descriptor[i + k - 2]).ds_length);
}
WRONG_PARAM_COUNT;
}
- args = (zval ***) emalloc(sizeof(zval **) * ZEND_NUM_ARGS());
+ args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS());
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
efree(args);
RETURN_FALSE;
if (ar_cnt) { /* have arrays ? */
*array_cntp = ar_cnt;
- IB_ARRAY = emalloc(sizeof(ibase_array)*ar_cnt);
+ IB_ARRAY = safe_emalloc(sizeof(ibase_array), ar_cnt, 0);
ar_cnt = 0;
var = sqlda->sqlvar;
for (i = 0; i < sqlda->sqld; i++, var++) {
for (i = 0; i < sqlda->sqld; i++, var++) {
switch (var->sqltype & ~1) {
case SQL_TEXT:
- var->sqldata = emalloc(sizeof(char) * (var->sqllen));
+ var->sqldata = safe_emalloc(sizeof(char), (var->sqllen), 0);
break;
case SQL_VARYING:
- var->sqldata = emalloc(sizeof(char) * (var->sqllen + sizeof(short)));
+ var->sqldata = safe_emalloc(sizeof(char), (var->sqllen + sizeof(short)), 0);
break;
case SQL_SHORT:
var->sqldata = emalloc(sizeof(short));
_php_ibase_alloc_xsqlda(out_sqlda);
if (ib_query->out_array) {
- IB_RESULT->out_array = emalloc(sizeof(ibase_array) * ib_query->out_array_cnt);
+ IB_RESULT->out_array = safe_emalloc(sizeof(ibase_array), ib_query->out_array_cnt, 0);
memcpy(IB_RESULT->out_array, ib_query->out_array, sizeof(ibase_array) * ib_query->out_array_cnt);
} else {
IB_RESULT->out_array = NULL;
}
in_sqlda = emalloc(XSQLDA_LENGTH(ib_query->in_sqlda->sqld));
memcpy(in_sqlda, ib_query->in_sqlda, XSQLDA_LENGTH(ib_query->in_sqlda->sqld));
- bind_buf = emalloc(sizeof(BIND_BUF) * ib_query->in_sqlda->sqld);
+ bind_buf = safe_emalloc(sizeof(BIND_BUF), ib_query->in_sqlda->sqld, 0);
if (_php_ibase_bind(in_sqlda, args, bind_buf, ib_query TSRMLS_CC) == FAILURE) {
IBDEBUG("Could not bind input XSQLDA");
goto _php_ibase_exec_error;
}
/* register the transaction in our own data structures */
- ib_trans = (ibase_trans *) emalloc(sizeof(ibase_trans) + (link_cnt-1)*sizeof(ibase_db_link *));
+ ib_trans = (ibase_trans *) safe_emalloc((link_cnt-1), sizeof(ibase_db_link *), sizeof(ibase_trans));
ib_trans->handle = tr_handle;
ib_trans->link_cnt = link_cnt;
ib_trans->affected_rows = 0;
data = ((IBASE_VCHAR *) data)->var_str;
/* fallout */
case SQL_TEXT:
- Z_STRVAL_P(val) = (char *) emalloc(sizeof(char) * (len + 1));
+ Z_STRVAL_P(val) = (char *) safe_emalloc(sizeof(char), (len + 1), 0);
memcpy(Z_STRVAL_P(val), data, len);
Z_STRVAL_P(val)[len] = '\0';
if (PG(magic_quotes_runtime)) {
WRONG_PARAM_COUNT;
}
- args = (zval ***) emalloc(sizeof(zval **) * ZEND_NUM_ARGS());
+ args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
efree(args);
RETURN_FALSE;
countpair = zend_hash_num_elements(htTuples);
- pairs = (char **)emalloc(sizeof(char *) * countpair * 2);
+ pairs = (char **)safe_emalloc(sizeof(char *), countpair * 2, 0);
ELOG("have pairs");
int *column_types;
char computed_buf[16];
- column_types = (int *) emalloc(sizeof(int) * result->num_fields);
+ column_types = (int *) safe_emalloc(sizeof(int), result->num_fields, 0);
for (i=0; i<result->num_fields; i++) {
char *fname = (char *)dbcolname(mssql_ptr->link,i+1);
i=0;
if (!result->data) {
- result->data = (zval **) emalloc(sizeof(zval *)*MSSQL_ROWS_BLOCK*(++result->blocks_initialized));
+ result->data = (zval **) safe_emalloc(sizeof(zval *), MSSQL_ROWS_BLOCK*(++result->blocks_initialized), 0);
}
while (retvalue!=FAIL && retvalue!=NO_MORE_ROWS) {
result->num_rows++;
if (result->num_rows > result->blocks_initialized*MSSQL_ROWS_BLOCK) {
result->data = (zval **) erealloc(result->data,sizeof(zval *)*MSSQL_ROWS_BLOCK*(++result->blocks_initialized));
}
- result->data[i] = (zval *) emalloc(sizeof(zval)*result->num_fields);
+ result->data[i] = (zval *) safe_emalloc(sizeof(zval), result->num_fields, 0);
for (j=0; j<result->num_fields; j++) {
INIT_ZVAL(result->data[i][j]);
MS_SQL_G(get_column_content(mssql_ptr, j+1, &result->data[i][j], column_types[j] TSRMLS_CC));
result->cur_field=result->cur_row=result->num_rows=0;
if (num_fields > 0) {
- result->fields = (mssql_field *) emalloc(sizeof(mssql_field)*result->num_fields);
+ result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), result->num_fields, 0);
result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue TSRMLS_CC);
}
else
retvalue = dbnextrow(mssql_ptr->link);
result->num_fields = dbnumcols(mssql_ptr->link);
- result->fields = (mssql_field *) emalloc(sizeof(mssql_field)*result->num_fields);
+ result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), result->num_fields, 0);
result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue TSRMLS_CC);
RETURN_TRUE;
}
result = (mssql_result *) emalloc(sizeof(mssql_result));
result->batchsize = batchsize;
result->blocks_initialized = 1;
- result->data = (zval **) emalloc(sizeof(zval *)*MSSQL_ROWS_BLOCK);
+ result->data = (zval **) safe_emalloc(sizeof(zval *), MSSQL_ROWS_BLOCK);
result->mssql_ptr = mssql_ptr;
result->cur_field=result->cur_row=result->num_rows=0;
result->num_fields = num_fields;
- result->fields = (mssql_field *) emalloc(sizeof(mssql_field)*num_fields);
+ result->fields = (mssql_field *) safe_emalloc(sizeof(mssql_field), num_fields);
result->num_rows = _mssql_fetch_batch(mssql_ptr, result, retvalue TSRMLS_CC);
result->statement = statement;
}
* be worth it
*/
- Z_STRVAL_P(return_value) = (char *) emalloc(Z_STRLEN_PP(str)*2+1);
+ Z_STRVAL_P(return_value) = (char *) safe_emalloc(Z_STRLEN_PP(str), 2, 1);
Z_STRLEN_P(return_value) = mysql_escape_string(Z_STRVAL_P(return_value), Z_STRVAL_PP(str), Z_STRLEN_PP(str));
Z_TYPE_P(return_value) = IS_STRING;
ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, &mysql_link, id, "MySQL-Link", le_link, le_plink);
- new_str = emalloc(str_len * 2 + 1);
+ new_str = safe_emalloc(str_len, 2, 1);
new_str_len = mysql_real_escape_string(&mysql->conn, new_str, str, str_len);
new_str = erealloc(new_str, new_str_len + 1);
php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE);
}
- args = (zval ***)emalloc(argc * sizeof(zval **));
+ args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
}
stmt->param.var_cnt = num_vars;
- stmt->param.vars = (zval **)emalloc(num_vars * sizeof(zval));
+ stmt->param.vars = (zval **)safe_emalloc(num_vars, sizeof(zval), 0);
for (i = 0; i < num_vars; i++) {
if (bind[i].buffer_type != MYSQLI_BIND_SEND_DATA) {
ZVAL_ADDREF(*args[i+start]);
WRONG_PARAM_COUNT;
}
- args = (zval ***)emalloc(argc * sizeof(zval **));
+ args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
}
stmt->result.var_cnt = var_cnt;
- stmt->result.vars = (zval **)emalloc((var_cnt) * sizeof(zval));
+ stmt->result.vars = (zval **)safe_emalloc((var_cnt), sizeof(zval), 0);
for (i = start; i < var_cnt+start; i++) {
ofs = i-start;
ZVAL_ADDREF(*args[i]);
}
MYSQLI_FETCH_RESOURCE(mysql, MYSQL *, prmysql, PR_MYSQL *, &mysql_link, "mysqli_link");
- newstr = emalloc(2 * escapestr_len + 1);
+ newstr = safe_emalloc(2, escapestr_len, 1);
newstr_len = mysql_real_escape_string(mysql, newstr, escapestr, escapestr_len);
newstr = erealloc(newstr, newstr_len + 1);
explain->columns = mysql_num_fields(res);
- explain->row = (PR_ROW *)emalloc(sizeof(PR_ROW) * explain->exp_cnt);
- explain->fields = (char **)emalloc(sizeof(char *) * explain->columns);
+ explain->row = (PR_ROW *)safe_emalloc(sizeof(PR_ROW), explain->exp_cnt, 0);
+ explain->fields = (char **)safe_emalloc(sizeof(char *), explain->columns, 0);
fields = mysql_fetch_fields(res);
}
for (i=0; i < explain->exp_cnt; i++) {
- explain->row[i].value = (char **)emalloc(sizeof(char *) * explain->columns);
+ explain->row[i].value = (char **)safe_emalloc(sizeof(char *), explain->columns, 0);
row = mysql_fetch_row(res);
for (j=0; j < explain->columns; j++) {
explain->row[i].value[j] = my_estrdup(row[j]);
}
if (flags & OCI_FETCHSTATEMENT_BY_ROW) {
- columns = emalloc(statement->ncolumns * sizeof(oci_out_column *));
+ columns = safe_emalloc(statement->ncolumns, sizeof(oci_out_column *), 0);
for (i = 0; i < statement->ncolumns; i++) {
columns[ i ] = oci_get_col(statement, i + 1, 0);
efree(columns);
} else { /* default to BY_COLUMN */
- columns = emalloc(statement->ncolumns * sizeof(oci_out_column *));
- outarrs = emalloc(statement->ncolumns * sizeof(zval*));
+ columns = safe_emalloc(statement->ncolumns, sizeof(oci_out_column *), 0);
+ outarrs = safe_emalloc(statement->ncolumns, sizeof(zval*), 0);
if (flags & OCI_NUM) {
for (i = 0; i < statement->ncolumns; i++) {
SWORD colnamelen; /* Not used */
SDWORD displaysize;
- result->values = (odbc_result_value *) emalloc(sizeof(odbc_result_value)*result->numcols);
+ result->values = (odbc_result_value *) safe_emalloc(sizeof(odbc_result_value), result->numcols, 0);
result->longreadlen = ODBCG(defaultlrl);
result->binmode = ODBCG(defaultbinmode);
}
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(pv_param_arr));
- params = (params_t *)emalloc(sizeof(params_t) * result->numparams);
+ params = (params_t *)safe_emalloc(sizeof(params_t), result->numparams, 0);
for(i = 1; i <= result->numparams; i++) {
if (zend_hash_get_current_data(Z_ARRVAL_PP(pv_param_arr), (void **) &tmp) == FAILURE) {
}
if (cursor->ncols > 0){
- cursor->columns = (oraColumn *) emalloc(sizeof(oraColumn) * cursor->ncols);
+ cursor->columns = (oraColumn *) safe_emalloc(sizeof(oraColumn), cursor->ncols, 0);
memset(cursor->columns,0,sizeof(oraColumn) * cursor->ncols);
}
return 1;
}
- new_statements = emalloc( (state->nstatements-1) * sizeof(STATEMENT));
+ new_statements = safe_emalloc( (state->nstatements-1), sizeof(STATEMENT), 0);
for (i=j=0;i<state->nstatements;i++) {
if (state->statements->statement != stmt) {
WRONG_PARAM_COUNT;
}
- args = (zval ***) emalloc(sizeof(zval **) * ZEND_NUM_ARGS());
+ args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to read parameters in pfpro_process_raw()");
WRONG_PARAM_COUNT;
}
- args = (zval ***) emalloc(sizeof(zval **) * ZEND_NUM_ARGS());
+ args = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0);
if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Unable to read parameters in pfpro_process()");
if (argc <= 0)
RETURN_FALSE
else
- args = (zval ***)emalloc(argc * sizeof(zval **));
+ args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
struct iovec *vector_array;
int i, j, num_vectors, argc = ZEND_NUM_ARGS();
- args = emalloc(argc*sizeof(zval**));
+ args = safe_emalloc(argc, sizeof(zval**), 0);
if (argc < 1 || zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
convert_to_long_ex(args[0]);
num_vectors = Z_LVAL_PP(args[0]);
- vector_array = emalloc(sizeof(struct iovec)*(num_vectors+1));
+ vector_array = safe_emalloc(sizeof(struct iovec), (num_vectors+1), 0);
for (i = 0, j = 1; i < num_vectors; i++, j++) {
convert_to_long_ex(args[j]);
ZEND_FETCH_RESOURCE(vector, php_iovec_t *, &iovec_id, -1, le_iov_name, le_iov);
- vector_array = (struct iovec*)emalloc(sizeof(struct iovec) * (vector->count + 2));
+ vector_array = (struct iovec*)safe_emalloc(sizeof(struct iovec), (vector->count + 2), 0);
memcpy(vector_array, vector->iov_array, sizeof(struct iovec) * vector->count);
vector_array[vector->count].iov_base = (char*)emalloc(iov_len);
RETURN_FALSE;
}
- vector_array = emalloc(vector->count * sizeof(struct iovec));
+ vector_array = safe_emalloc(vector->count, sizeof(struct iovec), 0);
for (i = 0; i < vector->count; i++) {
if (i < iov_pos) {
RETURN_TRUE;
}
- column_types = (int *) emalloc(sizeof(int) * num_fields);
+ column_types = (int *) safe_emalloc(sizeof(int), num_fields, 0);
for (i=0; i<num_fields; i++) {
column_types[i] = coltype(i+1);
}
result = (sybase_result *) emalloc(sizeof(sybase_result));
- result->data = (pval ***) emalloc(sizeof(pval **)*SYBASE_ROWS_BLOCK);
+ result->data = (pval ***) safe_emalloc(sizeof(pval **), SYBASE_ROWS_BLOCK, 0);
result->sybase_ptr = sybase_ptr;
result->cur_field=result->cur_row=result->num_rows=0;
result->num_fields = num_fields;
if (result->num_rows > blocks_initialized*SYBASE_ROWS_BLOCK) {
result->data = (pval ***) erealloc(result->data,sizeof(pval **)*SYBASE_ROWS_BLOCK*(++blocks_initialized));
}
- result->data[i] = (pval **) emalloc(sizeof(pval *)*num_fields);
+ result->data[i] = (pval **) safe_emalloc(sizeof(pval *), num_fields, 0);
for (j=1; j<=num_fields; j++) {
php_sybase_get_column_content(sybase_ptr, j, &result->data[i][j-1], column_types[j-1]);
if (!php_sybase_module.compatability_mode) {
}
result->num_rows = DBCOUNT(sybase_ptr->link);
- result->fields = (sybase_field *) emalloc(sizeof(sybase_field)*num_fields);
+ result->fields = (sybase_field *) safe_emalloc(sizeof(sybase_field), num_fields, 0);
j=0;
for (i=0; i<num_fields; i++) {
char *fname = dbcolname(sybase_ptr->link,i+1);
result->data = (zval **) erealloc(result->data, sizeof(zval *)*SYBASE_ROWS_BLOCK*(++result->blocks_initialized));
}
if (result->store || 1 == result->num_rows) {
- result->data[i] = (zval *) emalloc(sizeof(zval)*result->num_fields);
+ result->data[i] = (zval *) safe_emalloc(sizeof(zval), result->num_fields, 0);
}
for (j=0; j<result->num_fields; j++) {
}
result = (sybase_result *) emalloc(sizeof(sybase_result));
- result->data = (zval **) emalloc(sizeof(zval *)*SYBASE_ROWS_BLOCK);
+ result->data = (zval **) safe_emalloc(sizeof(zval *), SYBASE_ROWS_BLOCK, 0);
result->fields = NULL;
result->sybase_ptr = sybase_ptr;
result->cur_field=result->cur_row=result->num_rows=0;
result->last_retcode = 0;
result->store= store;
result->blocks_initialized= 1;
- result->tmp_buffer = (char **) emalloc(sizeof(char *)*num_fields);
- result->lengths = (CS_INT *) emalloc(sizeof(CS_INT)*num_fields);
- result->indicators = (CS_SMALLINT *) emalloc(sizeof(CS_INT)*num_fields);
- result->datafmt = (CS_DATAFMT *) emalloc(sizeof(CS_DATAFMT)*num_fields);
- result->numerics = (unsigned char *) emalloc(sizeof(unsigned char)*num_fields);
- result->types = (CS_INT *) emalloc(sizeof(CS_INT)*num_fields);
+ result->tmp_buffer = (char **) safe_emalloc(sizeof(char *), num_fields, 0);
+ result->lengths = (CS_INT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
+ result->indicators = (CS_SMALLINT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
+ result->datafmt = (CS_DATAFMT *) safe_emalloc(sizeof(CS_DATAFMT), num_fields, 0);
+ result->numerics = (unsigned char *) safe_emalloc(sizeof(unsigned char), num_fields, 0);
+ result->types = (CS_INT *) safe_emalloc(sizeof(CS_INT), num_fields, 0);
for (i=0; i<num_fields; i++) {
ct_describe(sybase_ptr->cmd, i+1, &result->datafmt[i]);
ct_bind(sybase_ptr->cmd, i+1, &result->datafmt[i], result->tmp_buffer[i], &result->lengths[i], &result->indicators[i]);
}
- result->fields = (sybase_field *) emalloc(sizeof(sybase_field)*num_fields);
+ result->fields = (sybase_field *) safe_emalloc(sizeof(sybase_field), num_fields, 0);
j=0;
for (i=0; i<num_fields; i++) {
char computed_buf[16];
WRONG_PARAM_COUNT;
}
- params = emalloc(sizeof(zval **) * argc);
+ params = safe_emalloc(sizeof(zval **), argc, 0);
if (zend_get_parameters_array_ex(argc, params) == FAILURE) {
efree(params);
if( j == 0 )
return NULL;
- retval = (unsigned char *)emalloc(sizeof(unsigned char) * j + 1);
+ retval = (unsigned char *)safe_emalloc(sizeof(unsigned char), j, 1);
retval[0] = (unsigned char)j;
curr_arg = *argument_list;
object_init_ex(obj, WG(type_ce));
ti->type = th;
- ti->values = emalloc(sizeof(zval *) * th->member_count);
+ ti->values = safe_emalloc(sizeof(zval *), th->member_count, 0);
memset(ti->values, '\0', sizeof(zval *) * th->member_count);
MAKE_STD_ZVAL(rsrc_handle);
WRONG_PARAM_COUNT
}
- params = (w32api_dynamic_param *)emalloc(sizeof(w32api_dynamic_param) * argc);
+ params = (w32api_dynamic_param *)safe_emalloc(sizeof(w32api_dynamic_param), argc, 0);
curr_arg = (*fh)->argument_list;
current_dynamic_param = params;
static int wddx_stack_init(wddx_stack *stack)
{
stack->top = 0;
- stack->elements = (void **) emalloc(sizeof(void **) * STACK_BLOCK_SIZE);
+ stack->elements = (void **) safe_emalloc(sizeof(void **), STACK_BLOCK_SIZE, 0);
stack->max = STACK_BLOCK_SIZE;
stack->varname = NULL;
stack->done = 0;
}
/* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval ***)emalloc(argc * sizeof(zval **));
+ args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
WRONG_PARAM_COUNT;
}
/* Allocate arguments array and get the arguments, checking for errors. */
- args = (zval ***)emalloc(argc * sizeof(zval **));
+ args = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
efree(args);
WRONG_PARAM_COUNT;
int result;
zend_fcall_info fci;
- args = emalloc(sizeof(zval **) * argc);
+ args = safe_emalloc(sizeof(zval **), argc, 0);
for (i = 0; i < argc; i++) {
args[i] = &argv[i];
}
}
/* This is the theoretical max (will never get beyond len * 2 as long
* as we are converting from single-byte characters, though) */
- newbuf = emalloc(len * 4 + 1);
+ newbuf = safe_emalloc(len, 4, 1);
while (pos > 0) {
c = encoder ? encoder((unsigned char)(*s)) : (unsigned short)(*s);
if (c < 0x80) {
if (info)
parser->info = *info;
parser->level = 0;
- parser->ltags = emalloc(XML_MAXLEVEL * sizeof(char *));
+ parser->ltags = safe_emalloc(XML_MAXLEVEL, sizeof(char *), 0);
XML_SetDefaultHandler(parser->parser, _xml_defaultHandler);
XML_SetElementHandler(parser->parser, _xml_startElementHandler, _xml_endElementHandler);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create XPath expression (string contains both quote and double-quotes)");
return NULL;
}
- value = (xmlChar*) emalloc (str_len * sizeof(xmlChar) );
+ value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);
snprintf(value, str_len, "'%s'", string);
} else {
- value = (xmlChar*) emalloc (str_len * sizeof(xmlChar) );
+ value = (xmlChar*) safe_emalloc (str_len, sizeof(xmlChar), 0);
snprintf(value, str_len, "\"%s\"", string);
}
return (char *) value;
in = *((struct in_addr *) host_info->h_addr);
}
- *sal = emalloc(2 * sizeof(*sal));
+ *sal = safe_emalloc(2, sizeof(*sal), 0);
sap = *sal;
*sap = emalloc(sizeof(struct sockaddr_in));
(*sap)->sa_family = AF_INET;
return 0;
}
- handles = (HANDLE*)emalloc((fd_count + sock_count) * sizeof(HANDLE));
+ handles = (HANDLE*)safe_emalloc((fd_count + sock_count), sizeof(HANDLE), 0);
/* populate the events and handles arrays */
f = 0;