Log Message: |
Fix memory leak in character translation caching.
If apr_xlate_open returned an error, some memory was allocated from a global
pool on every call. The problem is solved by caching a NULL handle in
this case.
Suggested by: jerenkrantz
kfogel
* subversion/libsvn_subr/utf.c
(xlate_handle_node_t): Add valid field.
(xlate_handle_node_cleanup): Set valid to FALSE instead of resetting the
handle.
(get_xlate_handle_node): Fix docstring.
Initialize valid field of allocated node struct.
Check the valid field instead of the handle field to make sure
the handle is valid. Avoid allocating a node if we're going to return an
error. Rename some variables for clarity.
(svn_utf_stringbuf_to_utf8, svn_utf_string_to_utf8,
svn_utf_stringbuf_from_utf8, svn_utf_string_from_utf8,
svn_utf_cstring_from_utf8, svn_utf_cstring_from_utf8_ex,
svn_utf_cstring_from_utf8_string): Make sure the xlate handle node
is always put back into the hash, even on errors and if there
is no handle.
|