nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 2ff398c68578bef389a27c9e429c2ee0e2b44d10
parent 4b24ce1c11fada30f4a5304e024fbe322f709939
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 15 Jan 2018 13:06:35 +0100

tweaks: reshuffle some stuff, and avoid a memory leak

Diffstat:
Msrc/rcfile.c | 23+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -774,22 +774,21 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright) return TRUE; } -/* Parse interface color options. */ +/* Parse the argument of an interface color option. */ colortype *parse_interface_color(char *combostr) { - short fg, bg; - bool bright = FALSE; - colortype *newcolor; - - if (!parse_color_names(combostr, &fg, &bg, &bright)) - return NULL; + colortype *trio = nmalloc(sizeof(colortype)); - newcolor = (colortype *)nmalloc(sizeof(colortype)); - newcolor->fg = fg; - newcolor->bg = bg; - newcolor->bright = bright; + trio->bright = FALSE; - return newcolor; + if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->bright)) { + free(combostr); + return trio; + } else { + free(combostr); + free(trio); + return NULL; + } } /* Read regex strings enclosed in double quotes from the line pointed at