fix leak in xcache.test=1; XCACHE_VERSION/XCACHE_MODULES length off-by-one
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@119 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
parent
fa7e0ab9f8
commit
32069e953f
11
mmap.c
11
mmap.c
|
@ -152,6 +152,7 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
|
|||
int ro_ok;
|
||||
volatile void *romem;
|
||||
char tmpname[sizeof(TMP_PATH) - 1 + 100];
|
||||
const char *errstr = NULL;
|
||||
|
||||
CHECK(shm = calloc(1, sizeof(xc_shm_t)), "shm OOM");
|
||||
shm->size = size;
|
||||
|
@ -177,11 +178,15 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
|
|||
if (fd == -1) {
|
||||
/* do not create file in /dev */
|
||||
if (strncmp(shm->name, "/dev", 4) == 0) {
|
||||
perror(shm->name);
|
||||
errstr = "Cannot open file set by xcache.mmap_path";
|
||||
goto err;
|
||||
}
|
||||
fd = open(shm->name, O_CREAT | O_RDWR, XCACHE_MMAP_PERMISSION);
|
||||
shm->newfile = 1;
|
||||
if (fd == -1) {
|
||||
perror(shm->name);
|
||||
errstr = "Cannot open or create file set by xcache.mmap_path";
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
@ -196,6 +201,8 @@ xc_shm_t *xc_shm_init(const char *path, xc_shmsize_t size, zend_bool readonly_pr
|
|||
#endif
|
||||
|
||||
if (shm->ptr == XCACHE_MAP_FAILED) {
|
||||
perror(shm->name);
|
||||
errstr = "Failed creating file mappping";
|
||||
shm->ptr = NULL;
|
||||
goto err;
|
||||
}
|
||||
|
@ -267,6 +274,10 @@ err:
|
|||
if (shm) {
|
||||
xc_shm_destroy(shm);
|
||||
}
|
||||
if (errstr) {
|
||||
fprintf(stderr, "%s\n", errstr);
|
||||
zend_error(E_ERROR, "%s", errstr);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
6
xcache.c
6
xcache.c
|
@ -938,6 +938,8 @@ err_bailout:
|
|||
zend_bailout();
|
||||
}
|
||||
if (xc_test && stored_xce) {
|
||||
destroy_op_array(op_array TSRMLS_CC);
|
||||
efree(op_array);
|
||||
goto restore;
|
||||
}
|
||||
return op_array;
|
||||
|
@ -1064,8 +1066,8 @@ static int xc_init_constant(int module_number TSRMLS_DC) /* {{{ */
|
|||
zend_register_long_constant(ZEND_STRS("XC_SIZEOF_TEMP_VARIABLE"), sizeof(temp_variable), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_long_constant(ZEND_STRS("XC_TYPE_PHP"), XC_TYPE_PHP, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_long_constant(ZEND_STRS("XC_TYPE_VAR"), XC_TYPE_VAR, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_stringl_constant(ZEND_STRS("XCACHE_VERSION"), ZEND_STRS(XCACHE_VERSION), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_stringl_constant(ZEND_STRS("XCACHE_MODULES"), ZEND_STRS(XCACHE_MODULES), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_stringl_constant(ZEND_STRS("XCACHE_VERSION"), ZEND_STRL(XCACHE_VERSION), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
zend_register_stringl_constant(ZEND_STRS("XCACHE_MODULES"), ZEND_STRL(XCACHE_MODULES), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
|
Loading…
Reference in New Issue