]> git.wh0rd.org Git - nano.git/commitdiff
- Memory leak fixes for files.c:do_insertfile(),do_browser(), nano.c:do_spell(),...
authorChris Allegretta <chrisa@asty.org>
Wed, 12 Feb 2003 02:52:04 +0000 (02:52 +0000)
committerChris Allegretta <chrisa@asty.org>
Wed, 12 Feb 2003 02:52:04 +0000 (02:52 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1449 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
files.c
nano.c
search.c

index ccc9fbbdf9e0eb416d8d314ddbbe6fe126063623..2de88eeec31be0a455a5d42c349357085484a926 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,8 @@ CVS code
          (David Benbennick).
        - Change ngettext macro to P_(), to avoid a clash with the reserved C
          __ identifier (Jordi).
+       - Memory leak fixes for files.c:do_insertfile(),do_browser(),
+         nano.c:do_spell(), and search.c:do_replace() (David Benbennick).
 - files.c:
   cwd_tab_completion()
        - Memory leak fix (David Benbennick).
diff --git a/files.c b/files.c
index b5c684776cea2957387a6a2499fe2346afc5b3e5..db4e5faa99830a1ff2fa2ce8e61e201a2985ba7c 100644 (file)
--- a/files.c
+++ b/files.c
@@ -503,9 +503,10 @@ int do_insertfile(int loading_file)
        if (i == NANO_TOFILES_KEY) {
            char *tmp = do_browse_from(answer);
 
-           if (tmp != NULL)
+           if (tmp != NULL) {
+               free(answer);
                answer = tmp;
-           else
+           else
                goto start_again;
        }
 #endif
@@ -2718,6 +2719,8 @@ char *do_browser(const char *inpath)
            }
 
            /* Start over again with the new path value */
+           free_charptrarray(filelist, numents);
+           free(foo);
            free(path);
            path = new_path;
            return do_browser(path);
diff --git a/nano.c b/nano.c
index 591d288723be8ada996532cc0754f031061d78e0..e6ce86e53a10be90372e14fae63e04658e1dd74c 100644 (file)
--- a/nano.c
+++ b/nano.c
@@ -1976,7 +1976,7 @@ int do_spell(void)
     nano_disabled_msg();
     return TRUE;
 #else
-    char *temp, *spell_msg = _("Generic error");
+    char *temp, *spell_msg;
 
     if ((temp = safe_tempnam(0, "nano.")) == NULL) {
        statusbar(_("Could not create a temporary filename: %s"),
@@ -2001,17 +2001,15 @@ int do_spell(void)
     else
        spell_msg = do_int_speller(temp);
     remove(temp);
+    free(temp);
 
-    if (spell_msg == NULL) {
-       statusbar(_("Finished checking spelling"));
-       return 1;
-    } else {
+    if (spell_msg != NULL) {
        statusbar(_("Spell checking failed: %s"), spell_msg);
        return 0;
     }
 
-    free(temp);
-
+    statusbar(_("Finished checking spelling"));
+    return 1;
 #endif
 }
 
index 0a074e59efb425c416addfe4e421153570cde6dc..ebf3fe8b4092bf7fe842016587086044ee50a3eb 100644 (file)
--- a/search.c
+++ b/search.c
@@ -763,6 +763,7 @@ int do_replace(void)
     else
        not_found_msg(prevanswer);
 
+    free(prevanswer);
     replace_abort();
     return 1;
 }