]> git.puffer.fish Git - mirror/frr.git/commit
vtysh: free memory given to us by readline 12443/head
authorDonald Sharp <sharpd@nvidia.com>
Mon, 5 Dec 2022 13:26:01 +0000 (08:26 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Mon, 5 Dec 2022 13:26:01 +0000 (08:26 -0500)
commit5098d577d201fe3c09893b4f1410b70f1ec58941
tree2b02623d1fba203e9ec0f790d70747fb4f735634
parentc7e804c900a6cac81ad0c726093e41f64b739bc0
vtysh: free memory given to us by readline

The rl_callback_handler_install function manual says this:

Set up the terminal for Readline I/O and display the initial expanded value of prompt.
Save the value of lhandler to use as a handler function to call when a complete line
of input has been entered. The handler function receives the text of the line as an
argument. As with readline(), the handler function should free the line when it is
finished with it.

Adding a free removes this memory leak that I am seeing with address sanitizer enabled;

SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s).:
2022-12-05 07:50:57,231 INFO: topolog.r7: vtysh result:
Hello, this is FRRouting (version 8.5-dev).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

r7# clear log cmdline-targets
r7# conf t
r7(config)# log file staticd.log debug
r7(config)# log commands
r7(config)# log timestamp precision 3
r7(config)#

=================================================================
==976989==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 99 byte(s) in 5 object(s) allocated from:
    #0 0x49cadd in malloc (/usr/bin/vtysh+0x49cadd)
    #1 0x7fc57135d8e8 in xmalloc build/shlib/./xmalloc.c:59:10

SUMMARY: AddressSanitizer: 99 byte(s) leaked in 5 allocation(s).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
vtysh/vtysh_main.c