[med-svn] [aghermann] 12/31: ensure lua stack is large enough before invoking script

andrei zavada hmmr-guest at alioth.debian.org
Sun Nov 10 00:34:16 UTC 2013


This is an automated email from the git hooks/post-receive script.

hmmr-guest pushed a commit to branch WIP
in repository aghermann.

commit 102036509484ce6bbee34205d22072d166c1d5e7
Author: Andrei Zavada <hmmr at ra>
Date:   Sat Nov 9 13:43:25 2013 +0200

    ensure lua stack is large enough before invoking script
---
 upstream/src/aghermann/rk1968/rk1968.cc |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/upstream/src/aghermann/rk1968/rk1968.cc b/upstream/src/aghermann/rk1968/rk1968.cc
index 9bc3444..b34c8e5 100644
--- a/upstream/src/aghermann/rk1968/rk1968.cc
+++ b/upstream/src/aghermann/rk1968/rk1968.cc
@@ -228,9 +228,12 @@ host_get_data( lua_State *L)
         case op_get_channel_list: {
                 NEED_ARITY_EXACT(0);
 
+                if ( !lua_checkstack( L, 1 + E.recordings.size()) )
+                        make_error_return( "Failed to grow stack for %d elements", 1 + (int)E.recordings.size());
                 lua_pushinteger( L, E.recordings.size());
                 for ( auto& H : E.recordings )
                         lua_pushstring( L, H.first.c_str());
+
                 return 1 + E.recordings.size();
         }
 
@@ -243,10 +246,14 @@ host_get_data( lua_State *L)
                 for ( auto& H : E.recordings )
                         if ( 0 == strcasecmp( H.first.type_s(), type) )
                                 ++hh_of_type;
+                if ( !lua_checkstack( L, 1 + hh_of_type) )
+                        make_error_return( "Failed to grow stack for %d elements", 1 + (int)hh_of_type);
+
                 lua_pushinteger( L, hh_of_type);
                 for ( auto& H : E.recordings )
                         if ( 0 == strcasecmp( H.first.type_s(), type) )
                                 lua_pushstring( L, H.first.c_str());
+
                 return 1 + hh_of_type;
         }
 
@@ -259,6 +266,8 @@ host_get_data( lua_State *L)
                         make_error_return( "No such channel (%s)", channel);
                 } else {
                         auto& R = Hi->second;
+                        if ( !lua_checkstack( L, 4) )
+                                make_error_return( "Failed to grow stack for 4 elements");
                         lua_pushinteger( L, R.full_pages());
                         lua_pushinteger( L, R.total_pages());
                         lua_pushinteger( L, R.pagesize());

-- 
Alioth's /git/debian-med/git-commit-notice on /srv/git.debian.org/git/debian-med/aghermann.git



More information about the debian-med-commit mailing list