From 6ff9dc2fdbe7ffd2f8a6c9ffe9ec801d53c760ba Mon Sep 17 00:00:00 2001
From: Eric Covener <covener@apache.org>
Date: Fri, 5 Jun 2026 10:05:36 +0000
Subject: [PATCH] Merge r1935005 from trunk:

merge_response_headers: fix lang iteration

reviewed by: covener, jfclere, jorton


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1935006 13f79535-47bb-0310-9956-ffa450edef68

Conflict:context adapte
Reference:https://github.com/apache/httpd/commit/6ff9dc2fdbe7ffd2f8a6c9ffe9ec801d53c760ba
---
 modules/http/http_filters.c  | 2 +-
 modules/http2/h2_c2_filter.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c
index 9f7f3fc..51b1126 100644
--- a/modules/http/http_filters.c
+++ b/modules/http/http_filters.c
@@ -1386,10 +1386,10 @@ static void merge_response_headers(request_rec *r, const char **protocol)
     if (!apr_is_empty_array(r->content_languages)) {
         int i;
         char *token;
-        char **languages = (char **)(r->content_languages->elts);
         const char *field = apr_table_get(r->headers_out, "Content-Language");
 
         while (field && (token = ap_get_list_item(r->pool, &field)) != NULL) {
+            char **languages = (char **)(r->content_languages->elts);
             for (i = 0; i < r->content_languages->nelts; ++i) {
                 if (!ap_cstr_casecmp(token, languages[i]))
                     break;
diff --git a/modules/http2/h2_c2_filter.c b/modules/http2/h2_c2_filter.c
index 554f88b..bb5d0ae 100644
--- a/modules/http2/h2_c2_filter.c
+++ b/modules/http2/h2_c2_filter.c
@@ -307,11 +307,11 @@ static h2_headers *create_response(request_rec *r)
     if (!apr_is_empty_array(r->content_languages)) {
         int i;
         char *token;
-        char **languages = (char **)(r->content_languages->elts);
         const char *field = apr_table_get(r->headers_out, "Content-Language");
 
         while (field && (token = ap_get_list_item(r->pool, &field)) != NULL) {
-            for (i = 0; i < r->content_languages->nelts; ++i) {
+            char **languages = (char **)(r->content_languages->elts);
+    		for (i = 0; i < r->content_languages->nelts; ++i) {
                 if (!apr_strnatcasecmp(token, languages[i]))
                     break;
             }
-- 
2.43.0