You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2025/06/02 14:48:54 UTC
svn commit: r1926063 - in /httpd/httpd/branches/2.4.x: ./ changes-entries/pr69590.txt modules/lua/mod_lua.c
Author: jorton
Date: Mon Jun 2 14:48:53 2025
New Revision: 1926063
URL: http://svn.apache.org/viewvc?rev=1926063&view=rev
Log:
Merge r1924095 from trunk:
mod_lua: Fix memory handling in output filters.
* modules/lua/mod_lua.c (lua_output_filter_handle): Fix brigade
iteration to use constant memory.
Submitted by: G.Grandes <guillermo.grandes gmail.com>
PR: 69590
Github: closes #517
Reviewed by: jorton, rpluem, covener
Added:
httpd/httpd/branches/2.4.x/changes-entries/pr69590.txt
- copied unchanged from r1924095, httpd/httpd/trunk/changes-entries/pr69590.txt
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1924095
Modified: httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c?rev=1926063&r1=1926062&r2=1926063&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c (original)
+++ httpd/httpd/branches/2.4.x/modules/lua/mod_lua.c Mon Jun 2 14:48:53 2025
@@ -473,14 +473,16 @@ static apr_status_t lua_output_filter_ha
L = ctx->L;
/* While the Lua function is still yielding, pass in buckets to the coroutine */
if (!ctx->broken) {
- for (pbktIn = APR_BRIGADE_FIRST(pbbIn);
- pbktIn != APR_BRIGADE_SENTINEL(pbbIn);
- pbktIn = APR_BUCKET_NEXT(pbktIn))
- {
+ while (!APR_BRIGADE_EMPTY(pbbIn)) {
const char *data;
apr_size_t len;
apr_bucket *pbktOut;
+ pbktIn = APR_BRIGADE_FIRST(pbbIn);
+ if (APR_BUCKET_IS_EOS(pbktIn)) {
+ break;
+ }
+
/* read the bucket */
apr_bucket_read(pbktIn,&data,&len,APR_BLOCK_READ);
@@ -514,10 +516,11 @@ static apr_status_t lua_output_filter_ha
lua_tostring(L, -1));
return HTTP_INTERNAL_SERVER_ERROR;
}
+ apr_bucket_delete(pbktIn);
}
/* If we've safely reached the end, do a final call to Lua to allow for any
finishing moves by the script, such as appending a tail. */
- if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pbbIn))) {
+ if (!APR_BRIGADE_EMPTY(pbbIn) && APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(pbbIn))) {
apr_bucket *pbktEOS;
lua_pushnil(L);
lua_setglobal(L, "bucket");