Re: [xml] Some things about xmlCharEncodingHandler

oliverst online de wrote:

I recognised several things about xmlCharEncodingHandlers.

First, you only register a handler, you can't unregister it. It makes
sense, because as I see from the source there is no
syncronisation/protection of the handlers, so you can't assure, that
it's not in use at the moment you would try to free it.

You can call xmlCleanupParser, that will remove the registered handlers :-)

Another thing is, that you can register several handlers with the same
name. And when you try to find a specific handler you only get the first
registered one with the name. Maybe there should be a check to prevent
more than one handler with the same name.

You have a patch handy?

I also recognised, that in the function xmlFindCharEncodingHandler() in
encoding.c the parameter "const char *name" is changed in the function.
The pointer will be set to the returning pointer of
xmlGetEncodingAlias(). IMO it should not be altered, because you might
want to use that var in the calling function with the (maybe wrong)
name. And I guess it causes a little memory leak. After the
xmlGetEncodingAlias call the var "nalias" should be used and "nalias"
set to name if the result was NULL.

The calling function will never see that change to name. Note that the pointer declared as 'const char* name' is local for the function, regardless wether it is declared in the parameter list or in the function body. The memory pointed to by this pointer wasn't modified.

As for the leak, where is it? I am failing to see it.


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