File 1400-Eliminate-potential-memory-leak-in-the-BEAM-loader.patch of Package erlang

From 8de030c7154298a318c0a711b86e6b65575c8225 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 20 Feb 2026 10:02:48 +0100
Subject: [PATCH 3/4] Eliminate potential memory leak in the BEAM loader

There could be a memory leak when attempting to load
invalid BEAM files.
---
 erts/emulator/beam/beam_load.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/erts/emulator/beam/beam_load.c b/erts/emulator/beam/beam_load.c
index 939abc922b..dbd8f86a59 100644
--- a/erts/emulator/beam/beam_load.c
+++ b/erts/emulator/beam/beam_load.c
@@ -595,6 +595,9 @@ static int load_code(LoaderState* stp)
                  * the instruction is obsolete.
                  */
                 if (num_specific == 0 && gen_opc[tmp_op->op].transform == -1) {
+                    beamopallocator_free_op(&stp->op_allocator,
+                                            stp->genop);
+                    stp->genop = NULL;
                     BeamLoadError0(stp, "please re-compile this module with an "
                                    ERLANG_OTP_RELEASE " compiler ");
                 }
@@ -631,6 +634,9 @@ static int load_code(LoaderState* stp)
                                        Mod, Name, arity);
                     }
                 default:
+                    beamopallocator_free_op(&stp->op_allocator,
+                                            stp->genop);
+                    stp->genop = NULL;
                     BeamLoadError0(stp, "no specific operation found");
                 }
             }
-- 
2.51.0

openSUSE Build Service is sponsored by