Re: [xml] [PATCH] encoding: fix memleak in xmlRegisterCharEncodingHandler()



On 07/12/2020 13:19, Xiaoming Ni wrote:
The return type of xmlRegisterCharEncodingHandler() is void. The invoker
cannot determine whether xmlRegisterCharEncodingHandler() is executed
successfully. when nbCharEncodingHandler >= MAX_ENCODING_HANDLERS, the
"handler" is not added to the array "handlers". As a result, the memory
of "handler" cannot be managed and released: memory leakage.

so add "xmlfree(handler)" to fix memory leakage on the failure branch of
xmlRegisterCharEncodingHandler().

Reported-by: wuqing <wuqing30 huawei com>
Signed-off-by: Xiaoming Ni <nixiaoming huawei com>
---
  encoding.c | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)

Merged here: https://gitlab.gnome.org/GNOME/libxml2/-/commit/649d02eaa419fa72ae6b131718a4ac77063d7a5a

Nick



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