Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTCEncodedFrame should have a virtual destructor #28757

Conversation

@rniwa rniwa self-assigned this May 18, 2024
@rniwa rniwa added the WebRTC For bugs in WebRTC label May 18, 2024
@@ -40,6 +40,8 @@ namespace WebCore {

class RTCEncodedFrame : public RefCounted<RTCEncodedFrame> {
public:
virtual ~RTCEncodedFrame() { }
Copy link
Contributor

@cdumez cdumez May 18, 2024

Choose a reason for hiding this comment

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

I don't think this is necessary? The constructor is marked as protected so no-one can destroy a RTCEncodedFrame directly. Having subclasses is fine as long as their destructor gets called first, which it would since the base class constructor is not public.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe it is necessary because of the way RefCounted calls delete? I have to look more into it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can't construct the base class, but you can

  • construct the subclass
  • cast the subclass pointer to the base class pointer
  • delete the base class pointer

In this case, I think that can mean that you fail to destroy RTCEncodedVideoFrame::m_metadata::dependencies (which is a Vector).

Copy link
Contributor

@cdumez cdumez left a comment

Choose a reason for hiding this comment

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

Actually, looking and RefCounted::deref, I think this is indeed needed.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 18, 2024
@rniwa rniwa added unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing and removed merging-blocked Applied to prevent a change from being merged labels May 18, 2024
https://bugs.webkit.org/show_bug.cgi?id=274353

Reviewed by Chris Dumez.

Added a virtual destructor since this class has subclasses.

* Source/WebCore/Modules/mediastream/RTCEncodedFrame.h:
(WebCore::RTCEncodedFrame::~RTCEncodedFrame):

Canonical link: https://commits.webkit.org/278964@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/RTCEncodedFrame-should-have-a-virtual-destructor branch from 8bdd6b6 to 5ccae9e Compare May 18, 2024 22:16
@webkit-commit-queue webkit-commit-queue merged commit 5ccae9e into WebKit:main May 18, 2024
@webkit-commit-queue
Copy link
Collaborator

Committed 278964@main (5ccae9e): https://commits.webkit.org/278964@main

Reviewed commits have been landed. Closing PR #28757 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label May 18, 2024
@rniwa rniwa deleted the eng/RTCEncodedFrame-should-have-a-virtual-destructor branch May 21, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebRTC For bugs in WebRTC
Projects
None yet
6 participants