diff --git a/ChangeLog b/ChangeLog
index 276b5b6965726c8112b978fe349302ea840fb8df..92a629efc00e827a76a89f74f93963717f402cc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-15  Benno Schulenberg  <bensberg@justemail.net>
+	* src/files.c (read_file): Free not just the struct but also the
+	data it contains, and also when it is the first and only line.
+	This fixes Savannah bug #47153 reported by Mike Frysinger.
+
 2016-02-14  Benno Schulenberg  <bensberg@justemail.net>
 	* src/search.c (do_replace_loop): Make iterating through replacement
 	matches behave again like iterating through search matches: showing
diff --git a/src/files.c b/src/files.c
index 0282cb37ad667b6b85ff3eeb7ac4bf8af68d13ff..2fe1be905d872639ccfd440ff3acbc0c62e69af1 100644
--- a/src/files.c
+++ b/src/files.c
@@ -871,6 +871,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
 	/* If the file we got doesn't end in a newline, tack its last
 	 * line onto the beginning of the line at current. */
 	if (len > 0) {
+	    filestruct *dropline = fileptr;
 	    size_t current_len = strlen(openfile->current->data);
 
 	    /* Adjust the current x-coordinate to compensate for the
@@ -896,11 +897,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
 	    if (fileptr == openfile->filebot)
 		openfile->filebot = openfile->current;
 
-	    /* Move fileptr back one line and blow away the old fileptr,
-	     * since its text has been saved. */
+	    /* Step back one line, and blow away the unterminated line,
+	     * since its text has been copied into current. */
 	    fileptr = fileptr->prev;
-	    if (fileptr != NULL)
-		free(fileptr->next);
+	    delete_node(dropline);
 	}
 
 	/* Attach the line at current after the line at fileptr. */