}
/* we pass additional args to the respective handler */
- args = emalloc(ac * sizeof(zval *));
+ args = safe_emalloc(ac, sizeof(zval *), 0);
if (zend_get_parameters_array_ex(ac, args) != SUCCESS) {
FREENOW;
WRONG_PARAM_COUNT;
list_entry *le;
/* calculate hash */
- key = emalloc(keylen);
+ key = safe_emalloc(keylen, 1, 1);
+ key[keylen] = '\0';
keylen = 0;
for(i = 0; i < ac; i++) {
}
}
len = cdb_datalen(&cdb->c);
- new_entry = emalloc(len+1);
+ new_entry = safe_emalloc(len, 1, 1);
if (php_cdb_read(&cdb->c, new_entry, len, cdb_datapos(&cdb->c)) == -1) {
efree(new_entry);
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
- key = emalloc(klen + 1);
+ key = safe_emalloc(klen, 1, 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
uint32_unpack(buf, &klen);
uint32_unpack(buf + 4, &dlen);
- key = emalloc(klen + 1);
+ key = safe_emalloc(klen, 1, 1);
if (cdb_file_read(cdb->file, key, klen) < klen) {
efree(key);
key = NULL;
head = c->head;
if (!head || (head->num >= CDB_HPLIST)) {
- head = (struct cdb_hplist *)
- emalloc(sizeof(struct cdb_hplist));
+ head = (struct cdb_hplist *) emalloc(sizeof(struct cdb_hplist));
if (!head)
return -1;
head->num = 0;
return -1;
}
- c->split = (struct cdb_hp *)
- emalloc(memsize * sizeof(struct cdb_hp));
+ c->split = (struct cdb_hp *) safe_emalloc(memsize, sizeof(struct cdb_hp), 0);
if (!c->split)
return -1;
if (flatfile_findkey(dba, key_datum TSRMLS_CC)) {
if (php_stream_gets(dba->fp, buf, sizeof(buf))) {
value_datum.dsize = atoi(buf);
- value_datum.dptr = emalloc(value_datum.dsize+1);
+ value_datum.dptr = safe_emalloc(value_datum.dsize, 1, 1);
value_datum.dsize = php_stream_read(dba->fp, value_datum.dptr, value_datum.dsize);
} else {
value_datum.dptr = NULL;