Skip to content

Fix Coverity issue in inliner plugin.#10442

Merged
ywkaras merged 2 commits intoapache:masterfrom
ywkaras:inliner_coverity
Sep 19, 2023
Merged

Fix Coverity issue in inliner plugin.#10442
ywkaras merged 2 commits intoapache:masterfrom
ywkaras:inliner_coverity

Conversation

@ywkaras
Copy link
Copy Markdown
Contributor

@ywkaras ywkaras commented Sep 14, 2023

CID 1508893

@ywkaras ywkaras self-assigned this Sep 14, 2023
@ywkaras ywkaras added this to the 10.0.0 milestone Sep 14, 2023
@ywkaras ywkaras linked an issue Sep 14, 2023 that may be closed by this pull request
@zwoop zwoop requested a review from cmcfarlen September 15, 2023 16:11
@zwoop
Copy link
Copy Markdown
Contributor

zwoop commented Sep 15, 2023

I think this looks good, but I'd like @cmcfarlen to review.

ats::io::IO *const io = new io::IO();
std::unique_ptr<ats::io::IO> io{new io::IO()};

TSDebug(PLUGIN_TAG, "request:\n%s", request.c_str());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what exactly Coverity's gripe is. My best guess is that it's seeing that *io would get leaked if TSDebug() threw an exception. But there must be a bazillion cases of that in our code, why would it single this one out? Are there instructions anywhere about how to run Coverity, to be sure we've appeased it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No unfortunately we don’t have enough karma to run PRs against coverity. So it’ll have to land on master for the next schedule run, rinse repeats…

Copy link
Copy Markdown
Contributor

@cmcfarlen cmcfarlen Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like from reading the defect report, coverity doesn't trace into the second get call to see that it is indeed assigned eventually. The std::move will hopefully help it realize that ownership is handed off.

cmcfarlen
cmcfarlen previously approved these changes Sep 19, 2023
Copy link
Copy Markdown
Contributor

@cmcfarlen cmcfarlen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

request += "\r\n\r\n";

ats::io::IO *const io = new io::IO();
std::unique_ptr<ats::io::IO> io{new io::IO()};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinions on this nitpick, but this could be auto io = std::make_unique<io::IO>();

TSDebug(PLUGIN_TAG, "request:\n%s", request.c_str());

ats::get(io, io->copy(request), AnotherClass(src_));
auto r{io->copy(request)};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to check what copy returned. A better name for r might be size or sz.

ats::io::IO *const io = new io::IO();
std::unique_ptr<ats::io::IO> io{new io::IO()};

TSDebug(PLUGIN_TAG, "request:\n%s", request.c_str());
Copy link
Copy Markdown
Contributor

@cmcfarlen cmcfarlen Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like from reading the defect report, coverity doesn't trace into the second get call to see that it is indeed assigned eventually. The std::move will hopefully help it realize that ownership is handed off.

@ywkaras
Copy link
Copy Markdown
Contributor Author

ywkaras commented Sep 19, 2023

[approve ci autest]

@ywkaras ywkaras merged commit 78d4343 into apache:master Sep 19, 2023
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jun 3, 2024
* asf/master: (30 commits)
  add conveinience function to lookup name->IntType* (apache#10474)
  cmake: bigobj subdir has executables, not plugins (apache#10481)
  cmake: compile jsonrpc_protocol with -fPIC (apache#10478)
  Make sure new metrics are always considered (apache#10445)
  Refactor and rename restart metrics (apache#10472)
  Fix the SNI and HOST parsing properly (apache#10480)
  slice/Data.h: CID 1508924: Uninitialized scalar field (apache#10470)
  CID 1508882: initialize pointer (apache#10469)
  CID-1512726: Mute coverity, use explicit check for iterator use past end (apache#10467)
  Fix Coverity issue in inliner plugin. (apache#10442)
  Set the proper variable when find_package fails to find the package (apache#10468)
  CID1508860: double lock confusion (apache#10443)
  Stop using functions that are unavailable on the latest quiche (apache#10447)
  Add allow-plain server ports attribute (apache#9574)
  [Fuzzing] move build.sh in trafficserver (apache#10466)
  Some sort of "fix" to mute coverity. (apache#10451)
  CID-1512733: Fix coverity issue (apache#10452)
  Fix cmake autooptions (apache#10456)
  Cmake presets (apache#10457)
  This fixes CID 1518257 (apache#10404)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CID 1508893: Resource leak

3 participants