lib: fix memory leak in getcmdline()
getline() may allocate line1 even when it returns -1, and the caller
must free the buffer on the error path.
When batch input ends with a missing continuation line, getcmdline()
returns without freeing line1. This can be reproduced with:
printf 'link show \\\n' | ./ip/ip -batch -
Free line1 before returning. Valgrind reports 120 bytes definitely
lost before this change.
Fixes: c2f3a0f94de9 ("Fix batch mode, allow continuation, comments, etc.")
Signed-off-by: Mohammad abu saleh <ml.abusaleh.ml@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
1 file changed