diff --git a/src/tui/light.go b/src/tui/light.go
index fbc76f59f8083f6c3e67ee76181d5c0cc011231b..d8de4b66ce96b477c2c321af34bcd31980505eac 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -23,6 +23,7 @@ const (
 	defaultEscDelay = 100
 	escPollInterval = 5
 	offsetPollTries = 10
+	maxInputBuffer  = 10 * 1024
 )
 
 const consoleDevice string = "/dev/tty"
@@ -317,6 +318,13 @@ func (r *LightRenderer) getBytesInternal(buffer []byte, nonblock bool) []byte {
 		}
 		buffer = append(buffer, byte(c))
 		pc = c
+
+		// This should never happen under normal conditions,
+		// so terminate fzf immediately.
+		if len(buffer) > maxInputBuffer {
+			r.Close()
+			panic(fmt.Sprintf("Input buffer overflow (%d): %v", len(buffer), buffer))
+		}
 	}
 
 	return buffer