Sebastian Bergmann wrote:
> Yasuo Ohgaki wrote:
> 
>>I will change code so that ob_end_clean() (and other similar
>>functions) may not be called from inside ob_start() call back
>>function. It's easy one to fix :)
>>
>>This code does not make sense to me, but I may miss
>>something. Do you want any usefulness in this code?
> 
> 
>   Yasuo,
> 
>   of course the code snippet I posted makes no obvious sense, it is after
>   all only the shortest snippet of code that reproduces the segfault I
>   encountered.
> 
>   I am currently working on an application that registers a callback via
>   ob_start() and gets called this way with the whole output, which
>   happens to be XML, of the rest of the script as its input data.
> 
>   In this callback, I use the ext/xml functions to parse this XML data.
>   Now when, for instance, a parse error occurs, I need to emit an
>   appropriate error messsage, hence I need to stop the output buffering
>   and output something. And, at this point, it segfaults.
> 
>   I would rather see the possibility of calling ob_end_clean() in a
>   ob_start() callback function than removing this feature.
> 

If you really need to call ob_end_clean() (i.e. delete buffer) inside
ob_start() call back, we can do that as follows,

Set flag before calling callback function.
If flag is set and one of buffer deletion function is called
inside callback function, then set flag for deleting the buffer.
Check deletion flag and if it's set, delete the buffer.

It's easy to fix and has a little additional overhead.

Any comments?

--
Yasuo Ohgaki


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to