]> git.wh0rd.org Git - nano.git/commitdiff
Freeing the cutbuffer after use.
authorBenno Schulenberg <bensberg@justemail.net>
Wed, 2 Jul 2014 20:52:27 +0000 (20:52 +0000)
committerBenno Schulenberg <bensberg@justemail.net>
Wed, 2 Jul 2014 20:52:27 +0000 (20:52 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5055 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/text.c

index 440a274bcc162d6087ea13077dc7810a4461cdaa..f16633ef2de6ad0ac117c2f45bbc47a4baf34266 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,10 @@
 2014-07-02  Mark Majeres  <mark@engine12.com>
        * src/text.c (undo_cut, redo_cut, update_undo): Handle the
-       cases of cutting-from-cursor-to-end-of-line properly.
+       cases of cutting-from-cursor-to-end-of-line correctly.
        * src/nano.c (do_input): Don't preserve the cutbuffer when
        CUT_TO_END is toggled -- it would intermix two cut types.
+       * src/text.c (redo_cut, do_undo, do_redo): Don't forget to
+       free the cutbuffer after use.
 
 2014-07-02  Benno Schulenberg  <bensberg@justemail.net>
        * src/proto.h: Add a typedef for a pointer to a function.
index 8cb4de3654d8c04b116fbaca51186e61f8623f92..807701aefec5154c2cc374c9aca934d9e667b0e6 100644 (file)
@@ -399,6 +399,10 @@ void redo_cut(undo *u)
     if (!u->cutbuffer)
        return;
 
+    filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
+    cutbuffer = NULL;
+    cutbottom = NULL;
+
     goto_line_posx(u->lineno, u->begin);
 
     if (ISSET(NO_NEWLINES) && openfile->current->lineno != u->lineno) {
@@ -416,6 +420,11 @@ void redo_cut(undo *u)
     openfile->mark_begin = NULL;
     openfile->mark_begin_x = 0;
     edit_refresh_needed = TRUE;
+
+    if (cutbuffer != NULL)
+       free_filestruct(cutbuffer);
+    cutbuffer = oldcutbuffer;
+    cutbottom = oldcutbottom;
 }
 
 /* Undo the last thing(s) we did. */
@@ -525,6 +534,8 @@ void do_undo(void)
        openfile->mark_set = TRUE;
        goto_line_posx(u->lineno, u->begin);
        cut_marked();
+       if (u->cutbuffer != NULL)
+           free_filestruct(u->cutbuffer);
        u->cutbuffer = cutbuffer;
        u->cutbottom = cutbottom;
        cutbuffer = oldcutbuffer;
@@ -656,6 +667,8 @@ void do_redo(void)
        redidmsg = _("text insert");
        goto_line_posx(u->lineno, u->begin);
        copy_from_filestruct(u->cutbuffer);
+       free_filestruct(u->cutbuffer);
+       u->cutbuffer = NULL;
        break;
     default:
        redidmsg = _("Internal error: unknown type.  Please save your work.");
@@ -924,6 +937,7 @@ void add_undo(undo_type current_action)
        break;
 #endif /* !DISABLE_WRAPPING */
     case INSERT:
+       break;
     case REPLACE:
        data = mallocstrcpy(NULL, fs->current->data);
        u->strdata = data;