From 27f2b258d3b8c0db90bf1e8b584a7beaae0e9c19 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Thu, 17 Mar 2005 05:08:15 +0000 Subject: [PATCH] initialize indent_string later in the justify code, so as to avoid a possible memory leak git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2385 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/nano.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nano.c b/src/nano.c index aa0be72f..3a8413fd 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2944,7 +2944,7 @@ void do_justify(bool full_justify) /* Number of lines in the paragraph we justify. */ ssize_t break_pos; /* Where we will break lines. */ - char *indent_string = mallocstrcpy(NULL, ""); + char *indent_string; /* The first indentation that doesn't match the initial * indentation of the paragraph we justify. This is put at * the beginning of every line broken off the first @@ -2985,6 +2985,9 @@ void do_justify(bool full_justify) first_par_line = backup_lines(current, full_justify ? filebot->lineno - current->lineno : par_len, quote_len); + /* Initialize indent_string to a blank string. */ + indent_string = mallocstrcpy(NULL, ""); + /* Find the first indentation in the paragraph that doesn't * match the indentation of the first line, and save it in * indent_string. If all the indentations are the same, save @@ -3141,7 +3144,6 @@ void do_justify(bool full_justify) /* We're done breaking lines, so we don't need indent_string * anymore. */ free(indent_string); - indent_string = NULL; /* Go to the next line, the line after the last line of the * paragraph. */ -- 2.39.5