summaryrefslogtreecommitdiff
path: root/backport-Fix-some-Lua-stack-leaks-in-our-initialization-code.patch
blob: 7166cceb1d2a01746c6f07a5daa958c7fca7d290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 3aa1abc4cabaa77bd9d3d05064466990d7e68a59 Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 18 Nov 2021 11:53:17 +0200
Subject: [PATCH] Fix some Lua stack leaks in our initialization code

---
 rpmio/rpmlua.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index 8459cd8..6ad9119 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -131,14 +131,18 @@ rpmlua rpmluaNew()
 
     for (lib = extlibs; lib->name; lib++) {
 	luaL_requiref(L, lib->name, lib->func, 1);
+	lua_pop(L, 1);
     }
     lua_pushcfunction(L, rpm_print);
     lua_setglobal(L, "print");
 
     lua_getglobal(L, "os");
     luaL_setfuncs(L, os_overrides, 0);
+    lua_pop(L, 1);
+
     lua_getglobal(L, "posix");
     luaL_setfuncs(L, posix_overrides, 0);
+    lua_pop(L, 1);
 
     lua_getglobal(L, "package");
     lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua");
-- 
1.8.3.1