Re: [xml] Problem in case of Failure of xmlGetGlobalState

On Mon, Apr 07, 2008 at 08:42:48PM +0530, ashwin sinha wrote:
This is with reference to the xmlGetGlobalState function. If this function
returns NULL due to a failure in xmlNewGlobalState function, then it will
lead to a crash in functions like     __xmlBufferAllocScheme on the line
       return (&xmlGetGlobalState()->xmlBufferAllocScheme);

  There are a number of functions like this in globals.c and all of them
will have the same problem.
    At first i thought having a check for the return value of
xmlGetGlobalState function would take care of the problem, but it will not,
because if we return NULL from there the macros defined in globals.h would
try to de-reference NULL pointers.

 So I am thinking we need to return a function pointer to a dummy
function(in case xmlGetGlobalState fails) which will always return NULL in
order to solve the problem. Is this the correct way to go about it, or is
there a better way?

  maybe give a pointer to a dummy static data structure instead.
But any error in the thread code will be had to handle correctly,
The best is to avoid global varaibles altogether...


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]