Copilot commented on code in PR #13591:
URL: https://github.com/apache/trafficserver/pull/13591#discussion_r4066306558


##########
plugins/header_rewrite/parser.cc:
##########
@@ -185,13 +185,20 @@ Parser::preprocess(std::vector<std::string> tokens)
               // This produces an error, but it's not fatal for load / reload. 
ToDo: ATS v11 fix.
               TSError("[%s] Duplicate modifier: %s", PLUGIN_NAME, t.c_str());
             } else {
-              _mods.push_back(t);
+              _mods.push_back(std::move(t));
             }
           }
         } else {
-          _mods.push_back(m);
+          _mods.push_back(std::move(m));
         }
         tokens.pop_back(); // consume it, so we don't concatenate it into the 
value
+        if (tokens.empty()) {
+          // Nothing is left to parse, and the code below indexes tokens[0]
+          // unconditionally. Reading it would touch the element pop_back() 
just
+          // destroyed, and _op would then take ownership of freed memory.
+          TSError("[%s] modifiers with no condition or operator to apply them 
to", PLUGIN_NAME);

Review Comment:
   This hunk adds a separate parser behavior fix: malformed modifier-only and 
condition-only lines now return `false` instead of reaching the unconditional 
`tokens[0]` accesses, and `header_rewrite_test.cc` adds regression coverage for 
it. The PR description currently presents the scope as only the string moves, 
so please document this behavior change (or split it out) so the parser error 
semantics are reviewed explicitly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to