File 5001-Return-empty-history-when-failing-to-create-a-log.patch of Package erlang

From 315f126fffa287bbd05813857f3fd824df67bb79 Mon Sep 17 00:00:00 2001
From: Frank Hunleth <fhunleth@troodon-software.com>
Date: Tue, 15 Mar 2022 11:53:40 -0400
Subject: [PATCH] Return empty history when failing to create a log

This fixes an infinite loop with group:up_stack/1 that could be
triggered when commandline history is enabled, but it wasn't possible to
create the log file. In this case, an `ok` atom was being stored as the
history which would confuse the history search.

If you pressed CTRL-R and started typing, an infinite loop would be
started that would eventually terminate when out of memory.

To reproduce:

```sh
$ export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_path '\"/proc\"'"
$ erl

Type CTRL-R and then press any key
```
---
 lib/kernel/src/group_history.erl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/kernel/src/group_history.erl b/lib/kernel/src/group_history.erl
index 3fee186879..2173628b4f 100644
--- a/lib/kernel/src/group_history.erl
+++ b/lib/kernel/src/group_history.erl
@@ -166,7 +166,8 @@ open_new_log(Name) ->
     case open_log() of
         {error, Reason} ->
             handle_open_error(Reason),
-            disable_history();
+            disable_history(),
+            [];
         _ ->
             _ = disk_log:close(Name),
             load()
-- 
2.34.1

openSUSE Build Service is sponsored by