From 35b67b15652102203161beb31db786f09981de81 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 24 Feb 2022 11:57:56 +0100
Subject: [PATCH 37/38] execute: don't crash when an empty buffer is piped
 through a command

That is, take into account that the cutbuffer could be NULL
(when updating the undo item).

This fixes https://savannah.gnu.org/bugs/?62107.

Bug existed since version 4.9, commit b15c5a7e.
---
 src/text.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/text.c b/src/text.c
index 5ff5745d..c88ca516 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1200,7 +1200,8 @@ void update_undo(undo_type action)
 		else if (cutbuffer != NULL) {
 			free_lines(u->cutbuffer);
 			u->cutbuffer = copy_buffer(cutbuffer);
-		}
+		} else
+			break;
 		if (!(u->xflags & MARK_WAS_SET)) {
 			linestruct *bottomline = u->cutbuffer;
 			size_t count = 0;
-- 
2.37.4

