Exemplo n.º 1
0
Arquivo: yod.c Projeto: qs9816/yodphp
/** {{{ int yod_do_exit(long status TSRMLS_DC)
*/
int yod_do_exit(long status TSRMLS_DC) {

#if PHP_YOD_DEBUG
	yod_debugf("yod_do_exit()");
	yod_debugs(TSRMLS_C);
#endif

	YOD_G(exited) = 1;
	EG(exit_status) = status;
	zend_set_memory_limit(PG(memory_limit));
	zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
	zend_bailout();

	return 1;
}
Exemplo n.º 2
0
/* {{{ PHP_INI_MH
 */
static PHP_INI_MH(suhosin_OnChangeMemoryLimit)
{
#if SIZEOF_LONG==8
	long hard_memory_limit = 0x7fffffffffffffff;
#elif SIZEOF_LONG==4
	long hard_memory_limit = 0x7fffffff;
#endif /* will produce a compile error or SIZEOF_LONG is not 4 or 8 */
	if (stage == ZEND_INI_STAGE_RUNTIME) {
		if (SUHOSIN_G(memory_limit) > 0) {
			SUHOSIN_G(hard_memory_limit) = SUHOSIN_G(memory_limit);
		} else if (SUHOSIN_G(hard_memory_limit) == 0) {
			SUHOSIN_G(hard_memory_limit) = PG(memory_limit);
		}
		hard_memory_limit = SUHOSIN_G(hard_memory_limit);
	} else {
		SUHOSIN_G(hard_memory_limit) = 0;
	}
	if (new_value) {
		PG(memory_limit) = zend_atol(new_value, new_value_length);
		if (hard_memory_limit > 0) {
			if (PG(memory_limit) > hard_memory_limit) {
				suhosin_log(S_MISC, "script tried to increase memory_limit to %lu bytes which is above the allowed value", PG(memory_limit));
				if (!SUHOSIN_G(simulation)) {
					PG(memory_limit) = hard_memory_limit;
					return FAILURE;
				}
			} else if (PG(memory_limit) < 0) {
				suhosin_log(S_MISC, "script tried to disable memory_limit by setting it to a negative value %ld bytes which is not allowed", PG(memory_limit));
				if (!SUHOSIN_G(simulation)) {
					PG(memory_limit) = hard_memory_limit;
					return FAILURE;
				}
			}
		}
	} else {
		PG(memory_limit) = hard_memory_limit;
	}
	return zend_set_memory_limit(PG(memory_limit));
}