bryancall commented on code in PR #13552:
URL: https://github.com/apache/trafficserver/pull/13552#discussion_r3803760550
##########
plugins/experimental/jax_fingerprint/plugin.cc:
##########
@@ -445,19 +451,17 @@ TSReturnCode
TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf
ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */)
{
Dbg(dbg_ctl, "New instance for client matching %s to %s", argv[0], argv[1]);
- auto config = new PluginConfig();
+ auto config = std::make_unique<PluginConfig>();
Review Comment:
Fixed in 34323cc. The two functions were using `config` for different
things, the `unique_ptr` in `TSRemapNewInstance` and the released raw pointer
in `TSPluginInit`. Both now spell the owning handle `owned_config` and the
released raw pointer `config`.
##########
plugins/experimental/stale_response/stale_response.cc:
##########
@@ -1070,6 +1070,10 @@ parse_args(int argc, char const *argv[])
plugin_config->log_info.stale_if_error = true;
break;
case 'd':
+ // The option may be repeated; release the previously duplicated name
first.
+ if (plugin_config->log_info.filename != PLUGIN_TAG) {
+ free(const_cast<char *>(plugin_config->log_info.filename));
Review Comment:
Yes, done in 34323cc, and it removed more than the cast. The field defaulted
to the static `PLUGIN_TAG`, which is what forced both the `const_cast` and the
`!= PLUGIN_TAG` pointer identity test that decided whether freeing was safe. It
now defaults to null and the tag is substituted at the point of use, so the
free is unconditional and the comparison is gone. That comparison was also
fragile: if the default ever became a `strdup`, it would have silently degraded
to a leak.
##########
plugins/xdebug/xdebug.cc:
##########
@@ -947,6 +947,7 @@ TSPluginInit(int argc, const char *argv[])
switch (opt) {
case 'h':
Dbg(dbg_ctl, "Setting header: %s", optarg);
+ TSfree(const_cast<char *>(xDebugHeader.str)); // The option can be
repeated, so the earlier value is not leaked
Review Comment:
Yes, done in 34323cc. `str` is only ever assigned a `TSstrdup` result, never
a literal, so `char *` is accurate and it removed a second `const_cast` at the
`TSUserArgSet` call as well.
--
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]