From: Ilia Alshanetsky Date: Mon, 15 Dec 2003 21:56:55 +0000 (+0000) Subject: Always set panic call handler, allows us to address critical libtidy errors X-Git-Tag: php-5.0.0b3RC1~54 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6a3f48d86fe5b801df261d4c123a149844e4f9d;p=php Always set panic call handler, allows us to address critical libtidy errors from inside PHP. When memory_limit is enabled use e* memory allocation macros to control memory usage. --- diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 1b77e1a712..c7c43bbe11 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -156,6 +156,7 @@ zend_module_entry tidy_module_entry = { ZEND_GET_MODULE(tidy) #endif +#if MEMORY_LIMIT void *php_tidy_malloc(size_t len) { return emalloc(len); @@ -170,13 +171,12 @@ void php_tidy_free(void *buf) { efree(buf); } - +#endif void php_tidy_panic(ctmbstr msg) { zend_error(E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg); } - static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file) { char *data=NULL, *cfg_file=NULL, *arg1; @@ -297,13 +297,13 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers * break; case is_doc: -/* for debugging of libtidy only +#if MEMORY_LIMIT tidySetMallocCall(php_tidy_malloc); tidySetReallocCall(php_tidy_realloc); tidySetFreeCall(php_tidy_free); - +#endif tidySetPanicCall(php_tidy_panic); -*/ + intern->ptdoc = emalloc(sizeof(PHPTidyDoc)); intern->ptdoc->doc = tidyCreate(); intern->ptdoc->parsed = FALSE;